Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #ifndef __FILE_LIST
00008 #define __FILE_LIST
00009
00010 #include "Export.h"
00011 #include "DS_List.h"
00012 #include "RakMemoryOverride.h"
00013 #include "RakNetTypes.h"
00014 #include "FileListNodeContext.h"
00015 #include "RakString.h"
00016
00017 #ifdef _MSC_VER
00018 #pragma warning( push )
00019 #endif
00020
00021 namespace RakNet
00022 {
00023 class BitStream;
00024 }
00025
00027 struct FileListNode
00028 {
00030 RakNet::RakString filename;
00031
00033 RakNet::RakString fullPathToFile;
00034
00036 char *data;
00037
00039 BitSize_t dataLengthBytes;
00040
00042 unsigned fileLengthBytes;
00043
00045 FileListNodeContext context;
00046
00048 bool isAReference;
00049 };
00050
00051
00052
00053 class RakPeerInterface;
00054 class FileList;
00055
00057 class RAK_DLL_EXPORT FileListProgress
00058 {
00059 public:
00060 FileListProgress() {}
00061 virtual ~FileListProgress() {}
00062
00064 virtual void OnAddFilesFromDirectoryStarted(FileList *fileList, char *dir) {
00065 (void) fileList;
00066 (void) dir;
00067 }
00068
00070 virtual void OnDirectory(FileList *fileList, char *dir, unsigned int directoriesRemaining) {
00071 (void) fileList;
00072 (void) dir;
00073 (void) directoriesRemaining;
00074 }
00075
00077 virtual void OnFile(FileList *fileList, char *dir, char *fileName, unsigned int fileSize) {
00078 (void) fileList;
00079 (void) dir;
00080 (void) fileName;
00081 (void) fileSize;
00082 }
00083
00091 virtual void OnFilePush(const char *fileName, unsigned int fileLengthBytes, unsigned int offset, unsigned int bytesBeingSent, bool done, SystemAddress targetSystem)
00092 {
00093 (void) fileName;
00094 (void) fileLengthBytes;
00095 (void) offset;
00096 (void) bytesBeingSent;
00097 (void) done;
00098 (void) targetSystem;
00099 }
00100 };
00101
00103 class RAK_DLL_EXPORT FLP_Printf : public FileListProgress
00104 {
00105 public:
00106 FLP_Printf() {}
00107 virtual ~FLP_Printf() {}
00108
00110 virtual void OnAddFilesFromDirectoryStarted(FileList *fileList, char *dir);
00111
00113 virtual void OnDirectory(FileList *fileList, char *dir, unsigned int directoriesRemaining);
00114 };
00115
00116 class RAK_DLL_EXPORT FileList
00117 {
00118 public:
00119 FileList();
00120 ~FileList();
00128 void AddFilesFromDirectory(const char *applicationDirectory, const char *subDirectory, bool writeHash, bool writeData, bool recursive, FileListNodeContext context);
00129
00131 void Clear(void);
00132
00134 void Serialize(RakNet::BitStream *outBitStream);
00135
00137 bool Deserialize(RakNet::BitStream *inBitStream);
00138
00146 void ListMissingOrChangedFiles(const char *applicationDirectory, FileList *missingOrChangedFiles, bool alwaysWriteHash, bool neverWriteHash);
00147
00155 void GetDeltaToCurrent(FileList *input, FileList *output, const char *dirSubset, const char *remoteSubdir);
00156
00162 void PopulateDataFromDisk(const char *applicationDirectory, bool writeFileData, bool writeFileHash, bool removeUnknownFiles);
00163
00166 void FlagFilesAsReferences(void);
00167
00170 void WriteDataToDisk(const char *applicationDirectory);
00171
00180 void AddFile(const char *filename, const char *fullPathToFile, const char *data, const unsigned dataLength, const unsigned fileLength, FileListNodeContext context, bool isAReference=false);
00181
00186 void AddFile(const char *filepath, const char *filename, FileListNodeContext context);
00187
00190 void DeleteFiles(const char *applicationDirectory);
00191
00194 void SetCallback(FileListProgress *cb);
00195
00196
00197 DataStructures::List<FileListNode> fileList;
00198
00199 static bool FixEndingSlash(char *str);
00200 protected:
00201 FileListProgress *callback;
00202 };
00203
00204 #ifdef _MSC_VER
00205 #pragma warning( pop )
00206 #endif
00207
00208 #endif