Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes

FileList Class Reference

#include <FileList.h>

Collaboration diagram for FileList:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 FileList ()
 ~FileList ()
void AddFilesFromDirectory (const char *applicationDirectory, const char *subDirectory, bool writeHash, bool writeData, bool recursive, FileListNodeContext context)
 Add all the files at a given directory.
void Clear (void)
 Deallocate all memory.
void Serialize (RakNet::BitStream *outBitStream)
 Write all encoded data into a bitstream.
bool Deserialize (RakNet::BitStream *inBitStream)
 Read all encoded data from a bitstream. Clear() is called before deserializing.
void ListMissingOrChangedFiles (const char *applicationDirectory, FileList *missingOrChangedFiles, bool alwaysWriteHash, bool neverWriteHash)
 Given the existing set of files, search applicationDirectory for the same files.
void GetDeltaToCurrent (FileList *input, FileList *output, const char *dirSubset, const char *remoteSubdir)
 Return the files that need to be written to make input match this current FileList.
void PopulateDataFromDisk (const char *applicationDirectory, bool writeFileData, bool writeFileHash, bool removeUnknownFiles)
 Assuming FileList contains a list of filenames presumably without data, read the data for these filenames.
void FlagFilesAsReferences (void)
void WriteDataToDisk (const char *applicationDirectory)
 Write all files to disk, prefixing the paths with applicationDirectory.
void AddFile (const char *filename, const char *fullPathToFile, const char *data, const unsigned dataLength, const unsigned fileLength, FileListNodeContext context, bool isAReference=false)
 Add a file, given data already in memory.
void AddFile (const char *filepath, const char *filename, FileListNodeContext context)
 Add a file, reading it from disk.
void DeleteFiles (const char *applicationDirectory)
 Delete all files stored in the file list.
void SetCallback (FileListProgress *cb)
 Set a callback to get progress reports about what this class does.

Static Public Member Functions

static bool FixEndingSlash (char *str)

Public Attributes

DataStructures::List
< FileListNode
fileList

Protected Attributes

FileListProgresscallback

Detailed Description

Definition at line 116 of file FileList.h.


Constructor & Destructor Documentation

FileList::FileList (  ) 

Definition at line 64 of file FileList.cpp.

FileList::~FileList (  ) 

Definition at line 68 of file FileList.cpp.

Here is the call graph for this function:


Member Function Documentation

void FileList::AddFile ( const char *  filename,
const char *  fullPathToFile,
const char *  data,
const unsigned  dataLength,
const unsigned  fileLength,
FileListNodeContext  context,
bool  isAReference = false 
)

Add a file, given data already in memory.

Parameters:
[in] filename Name of a file, optionally prefixed with a partial or complete path. Use \ as the path delineator.
[in] fullPathToFile Full path to the file on disk
[in] data Contents to write
[in] dataLength length of the data, which may be greater than fileLength should you prefix extra data, such as the hash
[in] fileLength Length of the file
[in] context User defined byte to store with each file. Use for whatever you want.
[in] isAReference Means that this is just a reference to a file elsewhere - does not actually have any data

Definition at line 120 of file FileList.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void FileList::AddFile ( const char *  filepath,
const char *  filename,
FileListNodeContext  context 
)

Add a file, reading it from disk.

Parameters:
[in] filepath Complete path to the file, including the filename itself
[in] filename filename to store internally, anything you want, but usually either the complete path or a subset of the complete path.
[in] context User defined byte to store with each file. Use for whatever you want.

Definition at line 72 of file FileList.cpp.

Here is the call graph for this function:

void FileList::AddFilesFromDirectory ( const char *  applicationDirectory,
const char *  subDirectory,
bool  writeHash,
bool  writeData,
bool  recursive,
FileListNodeContext  context 
)

Add all the files at a given directory.

Parameters:
[in] applicationDirectory The first part of the path. This is not stored as part of the filename. Use \ as the path delineator.
[in] subDirectory The rest of the path to the file. This is stored as a prefix to the filename
[in] writeHash The first SHA1_LENGTH bytes is a hash of the file, with the remainder the actual file data (should writeData be true)
[in] writeData Write the contents of each file
[in] recursive Whether or not to visit subdirectories
[in] context User defined byte to store with each file. Use for whatever you want.

Definition at line 170 of file FileList.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void FileList::Clear ( void   ) 

Deallocate all memory.

Definition at line 313 of file FileList.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void FileList::DeleteFiles ( const char *  applicationDirectory  ) 

Delete all files stored in the file list.

Parameters:
[in] applicationDirectory Prefixed to the path to each filename. Use \ as the path delineator.

Definition at line 656 of file FileList.cpp.

Here is the call graph for this function:

bool FileList::Deserialize ( RakNet::BitStream inBitStream  ) 

Read all encoded data from a bitstream. Clear() is called before deserializing.

Definition at line 343 of file FileList.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool FileList::FixEndingSlash ( char *  str  )  [static]

Definition at line 696 of file FileList.cpp.

Here is the caller graph for this function:

void FileList::FlagFilesAsReferences ( void   ) 

By default, GetDeltaToCurrent tags files as non-references, meaning they are assumed to be populated later This tags all files as references, required for IncrementalReadInterface to process them incrementally

Definition at line 617 of file FileList.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void FileList::GetDeltaToCurrent ( FileList input,
FileList output,
const char *  dirSubset,
const char *  remoteSubdir 
)

Return the files that need to be written to make input match this current FileList.

Specify dirSubset to only consider files that start with this path specify remoteSubdir to assume that all filenames in input start with this path, so strip it off when comparing filenames.

Parameters:
[in] input Full list of files
[out] output Files that we need to match input
[in] dirSubset If the filename does not start with this path, just skip this file.
[in] remoteSubdir Remove this from the filenames of input when comparing to existing filenames.

Definition at line 404 of file FileList.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void FileList::ListMissingOrChangedFiles ( const char *  applicationDirectory,
FileList missingOrChangedFiles,
bool  alwaysWriteHash,
bool  neverWriteHash 
)

Given the existing set of files, search applicationDirectory for the same files.

For each file that is missing or different, add that file to missingOrChangedFiles. Note: the file contents are not written, and only the hash if written if alwaysWriteHash is true alwaysWriteHash and neverWriteHash are optimizations to avoid reading the file contents to generate the hash if not necessary because the file is missing or has different lengths anyway.

Parameters:
[in] applicationDirectory The first part of the path. This is not stored as part of the filename. Use \ as the path delineator.
[out] missingOrChangedFiles Output list written to
[in] alwaysWriteHash If true, and neverWriteHash is false, will hash the file content of the file on disk, and write that as the file data with a length of SHA1_LENGTH bytes. If false, if the file length is different, will only write the filename.
[in] neverWriteHash If true, will never write the hash, even if available. If false, will write the hash if the file lengths are the same and it was forced to do a comparison.

Definition at line 473 of file FileList.cpp.

Here is the call graph for this function:

void FileList::PopulateDataFromDisk ( const char *  applicationDirectory,
bool  writeFileData,
bool  writeFileHash,
bool  removeUnknownFiles 
)

Assuming FileList contains a list of filenames presumably without data, read the data for these filenames.

Parameters:
[in] applicationDirectory Prepend this path to each filename. Trailing slash will be added if necessary. Use \ as the path delineator.
[in] writeFileData True to read and store the file data. The first SHA1_LENGTH bytes will contain the hash if writeFileHash is true
[in] writeFileHash True to read and store the hash of the file data. The first SHA1_LENGTH bytes will contain the hash if writeFileHash is true
[in] removeUnknownFiles If a file does not exist on disk but is in the file list, remove it from the file list?

Definition at line 532 of file FileList.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void FileList::Serialize ( RakNet::BitStream outBitStream  ) 

Write all encoded data into a bitstream.

Definition at line 322 of file FileList.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void FileList::SetCallback ( FileListProgress cb  ) 

Set a callback to get progress reports about what this class does.

Parameters:
[in] cb A pointer to an externally defined instance of FileListProgress. This pointer is held internally, so should remain valid as long as this class is valid.

Definition at line 691 of file FileList.cpp.

Here is the caller graph for this function:

void FileList::WriteDataToDisk ( const char *  applicationDirectory  ) 

Write all files to disk, prefixing the paths with applicationDirectory.

Parameters:
[in] applicationDirectory path prefix

Definition at line 625 of file FileList.cpp.

Here is the call graph for this function:


Member Data Documentation

Definition at line 201 of file FileList.h.

Definition at line 197 of file FileList.h.


The documentation for this class was generated from the following files: