SLikeNet 0.1.3

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes | List of all members
SLNet::FileList Class Reference

`#include <slikenet/FileList.h>`

## 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 (SLNet::BitStream *outBitStream)
| Write all encoded data into a bitstream.
bool | Deserialize (SLNet::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, 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 | DeleteFiles (const char *applicationDirectory)
| Delete all files stored in the file list.
void | AddCallback (FileListProgress *cb)
| Adds a callback to get progress reports about what the file list instances do.
void | RemoveCallback (FileListProgress *cb)
| Removes a callback.
void | ClearCallbacks (void)
| Removes all callbacks.
void | GetCallbacks (DataStructures::List< FileListProgress * > &callbacks)

## Static Public Member Functions

static bool | FixEndingSlash (char *str)
static bool | FixEndingSlash (char *str, size_t strLength)

## Public Attributes

DataStructures::List < FileListNode > | fileList

## Protected Attributes

DataStructures::List < FileListProgress * > | fileListProgressCallbacks

## Detailed Description

Definition at line 156 of file FileList.h.

## Constructor & Destructor Documentation

SLNet::FileList::FileList | ( |  | ) |

SLNet::FileList::~FileList | ( |  | ) |

## Member Function Documentation

void SLNet::FileList::AddCallback | ( | FileListProgress * | cb | ) |

Adds a callback to get progress reports about what the file list instances do.

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.

void SLNet::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`
| ) |  |

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
  [in] | takeDataPointer | If true, do not allocate dataLength. Just take the pointer passed to the data parameter

void SLNet::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.

void SLNet::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 4 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.

void SLNet::FileList::Clear | ( | void |  | ) |

Deallocate all memory.

void SLNet::FileList::ClearCallbacks | ( | void |  | ) |

Removes all callbacks.

void SLNet::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.

bool SLNet::FileList::Deserialize | ( | SLNet::BitStream * | inBitStream | ) |

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

static bool SLNet::FileList::FixEndingSlash | ( | char * | str | ) |

static

static bool SLNet::FileList::FixEndingSlash | ( | char * | str,
|  | size_t | strLength
| ) |  |

static

void SLNet::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 SLNet::FileList::GetCallbacks | ( | DataStructures::List< FileListProgress * > & | callbacks | ) |

Returns all callbacks added with AddCallback()

Parameters

  [out] | callbacks | The list is set to the list of callbacks

void SLNet::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.

void SLNet::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.

void SLNet::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?

void SLNet::FileList::RemoveCallback | ( | FileListProgress * | cb | ) |

Removes a callback.

Parameters

  [in] | cb | A pointer to an externally defined instance of FileListProgress that was previously added with AddCallback()

void SLNet::FileList::Serialize | ( | SLNet::BitStream * | outBitStream | ) |

Write all encoded data into a bitstream.

void SLNet::FileList::WriteDataToDisk | ( | const char * | applicationDirectory | ) |

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

Parameters

  [in] | applicationDirectory | path prefix

## Member Data Documentation

DataStructures::List<FileListNode> SLNet::FileList::fileList

Definition at line 252 of file FileList.h.

DataStructures::List<FileListProgress*> SLNet::FileList::fileListProgressCallbacks

protected

Definition at line 257 of file FileList.h.

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

- Source/include/slikenet/FileList.h