Shadowrun: Awakened 29 September 2011 - Build 871
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes
RakNet::FileList Class Reference

#include <FileList.h>

List of all members.

Public Member Functions

void AddCallback (FileListProgress *cb)
 Adds a callback to get progress reports about what the file list instances do.
void AddFile (const char *filename, const char *fullPathToFile, const char *data, const unsigned dataLength, const unsigned fileLength, FileListNodeContext context, bool isAReference=false, bool takeDataPointer=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 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 ClearCallbacks (void)
 Removes all callbacks.
void DeleteFiles (const char *applicationDirectory)
 Delete all files stored in the file list.
bool Deserialize (RakNet::BitStream *inBitStream)
 Read all encoded data from a bitstream. Clear() is called before deserializing.
 FileList ()
void FlagFilesAsReferences (void)
void GetCallbacks (DataStructures::List< FileListProgress * > &callbacks)
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 ListMissingOrChangedFiles (const char *applicationDirectory, FileList *missingOrChangedFiles, bool alwaysWriteHash, bool neverWriteHash)
 Given the existing set of files, search applicationDirectory for the same files.
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 RemoveCallback (FileListProgress *cb)
 Removes a callback.
void Serialize (RakNet::BitStream *outBitStream)
 Write all encoded data into a bitstream.
void WriteDataToDisk (const char *applicationDirectory)
 Write all files to disk, prefixing the paths with applicationDirectory.
 ~FileList ()

Static Public Member Functions

static void DestroyInstance (FileList *i)
static bool FixEndingSlash (char *str)
static FileListGetInstance (void)

Public Attributes

DataStructures::List
< FileListNode
fileList

Protected Attributes

DataStructures::List
< FileListProgress * > 
fileListProgressCallbacks

Detailed Description

Definition at line 145 of file FileList.h.


Constructor & Destructor Documentation

RakNet::FileList::FileList ( )
RakNet::FileList::~FileList ( )

Member Function Documentation

void RakNet::FileList::AddCallback ( FileListProgress cb)
Parameters:
[in]cbA pointer to an externally defined instance of FileListProgress. This pointer is held internally, so should remain valid as long as this class is valid.
void RakNet::FileList::AddFile ( const char *  filename,
const char *  fullPathToFile,
const char *  data,
const unsigned  dataLength,
const unsigned  fileLength,
FileListNodeContext  context,
bool  isAReference = false,
bool  takeDataPointer = false 
)
Parameters:
[in]filenameName of a file, optionally prefixed with a partial or complete path. Use \ as the path delineator.
[in]fullPathToFileFull path to the file on disk
[in]dataContents to write
[in]dataLengthlength of the data, which may be greater than fileLength should you prefix extra data, such as the hash
[in]fileLengthLength of the file
[in]contextUser defined byte to store with each file. Use for whatever you want.
[in]isAReferenceMeans that this is just a reference to a file elsewhere - does not actually have any data
[in]takeDataPointerIf true, do not allocate dataLength. Just take the pointer passed to the data parameter
void RakNet::FileList::AddFile ( const char *  filepath,
const char *  filename,
FileListNodeContext  context 
)
Parameters:
[in]filepathComplete path to the file, including the filename itself
[in]filenamefilename to store internally, anything you want, but usually either the complete path or a subset of the complete path.
[in]contextUser defined byte to store with each file. Use for whatever you want.
void RakNet::FileList::AddFilesFromDirectory ( const char *  applicationDirectory,
const char *  subDirectory,
bool  writeHash,
bool  writeData,
bool  recursive,
FileListNodeContext  context 
)
Parameters:
[in]applicationDirectoryThe first part of the path. This is not stored as part of the filename. Use \ as the path delineator.
[in]subDirectoryThe rest of the path to the file. This is stored as a prefix to the filename
[in]writeHashThe first 4 bytes is a hash of the file, with the remainder the actual file data (should writeData be true)
[in]writeDataWrite the contents of each file
[in]recursiveWhether or not to visit subdirectories
[in]contextUser defined byte to store with each file. Use for whatever you want.
void RakNet::FileList::Clear ( void  )
void RakNet::FileList::ClearCallbacks ( void  )
void RakNet::FileList::DeleteFiles ( const char *  applicationDirectory)
Parameters:
[in]applicationDirectoryPrefixed to the path to each filename. Use \ as the path delineator.
bool RakNet::FileList::Deserialize ( RakNet::BitStream inBitStream)
static void RakNet::FileList::DestroyInstance ( FileList i) [static]
static bool RakNet::FileList::FixEndingSlash ( char *  str) [static]
void RakNet::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

void RakNet::FileList::GetCallbacks ( DataStructures::List< FileListProgress * > &  callbacks)

Returns all callbacks added with AddCallback()

Parameters:
[out]callbacksThe list is set to the list of callbacks
void RakNet::FileList::GetDeltaToCurrent ( FileList input,
FileList output,
const char *  dirSubset,
const char *  remoteSubdir 
)

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]inputFull list of files
[out]outputFiles that we need to match input
[in]dirSubsetIf the filename does not start with this path, just skip this file.
[in]remoteSubdirRemove this from the filenames of input when comparing to existing filenames.
static FileList* RakNet::FileList::GetInstance ( void  ) [static]
void RakNet::FileList::ListMissingOrChangedFiles ( const char *  applicationDirectory,
FileList missingOrChangedFiles,
bool  alwaysWriteHash,
bool  neverWriteHash 
)

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]applicationDirectoryThe first part of the path. This is not stored as part of the filename. Use \ as the path delineator.
[out]missingOrChangedFilesOutput list written to
[in]alwaysWriteHashIf 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]neverWriteHashIf 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.
void RakNet::FileList::PopulateDataFromDisk ( const char *  applicationDirectory,
bool  writeFileData,
bool  writeFileHash,
bool  removeUnknownFiles 
)
Parameters:
[in]applicationDirectoryPrepend this path to each filename. Trailing slash will be added if necessary. Use \ as the path delineator.
[in]writeFileDataTrue to read and store the file data. The first SHA1_LENGTH bytes will contain the hash if writeFileHash is true
[in]writeFileHashTrue to read and store the hash of the file data. The first SHA1_LENGTH bytes will contain the hash if writeFileHash is true
[in]removeUnknownFilesIf a file does not exist on disk but is in the file list, remove it from the file list?
void RakNet::FileList::RemoveCallback ( FileListProgress cb)
Parameters:
[in]cbA pointer to an externally defined instance of FileListProgress that was previously added with AddCallback()
void RakNet::FileList::Serialize ( RakNet::BitStream outBitStream)
void RakNet::FileList::WriteDataToDisk ( const char *  applicationDirectory)
Parameters:
[in]applicationDirectorypath prefix

Member Data Documentation

Definition at line 241 of file FileList.h.

Definition at line 245 of file FileList.h.


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

Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.

GNU Lesser General Public License 3 Sourceforge.net