Shadowrun: Awakened 29 September 2011 - Build 871
FileList.h
Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 #include "NativeFeatureIncludes.h"
00008 #if _RAKNET_SUPPORT_FileOperations==1
00009 
00010 #ifndef __FILE_LIST
00011 #define __FILE_LIST
00012 
00013 #include "Export.h"
00014 #include "DS_List.h"
00015 #include "RakMemoryOverride.h"
00016 #include "RakNetTypes.h"
00017 #include "FileListNodeContext.h"
00018 #include "RakString.h"
00019 
00020 #ifdef _MSC_VER
00021 #pragma warning( push )
00022 #endif
00023 
00024 namespace RakNet
00025 {
00026     class BitStream;
00027 }
00028 
00029 namespace RakNet
00030 {
00032 class RakPeerInterface;
00033 class FileList;
00034 
00035 
00037 struct FileListNode
00038 {
00040     RakNet::RakString filename;
00041 
00043     RakNet::RakString fullPathToFile;
00044 
00046     char *data;
00047 
00049     BitSize_t dataLengthBytes;
00050 
00052     unsigned fileLengthBytes;
00053 
00055     FileListNodeContext context; 
00056 
00058     bool isAReference;
00059 };
00060 
00062 class RAK_DLL_EXPORT FileListProgress
00063 {
00064 public:
00065     // GetInstance() and DestroyInstance(instance*)
00066     STATIC_FACTORY_DECLARATIONS(FileListProgress)
00067 
00068     FileListProgress() {}
00069     virtual ~FileListProgress() {}
00070 
00072     virtual void OnAddFilesFromDirectoryStarted(FileList *fileList, char *dir) {
00073         (void) fileList;
00074         (void) dir;
00075     }
00076 
00078     virtual void OnDirectory(FileList *fileList, char *dir, unsigned int directoriesRemaining) {
00079         (void) fileList;
00080         (void) dir;
00081         (void) directoriesRemaining;
00082     }
00083 
00085     virtual void OnFile(FileList *fileList, char *dir, char *fileName, unsigned int fileSize) {
00086         (void) fileList;
00087         (void) dir;
00088         (void) fileName;
00089         (void) fileSize;
00090     }
00091 
00099     virtual void OnFilePush(const char *fileName, unsigned int fileLengthBytes, unsigned int offset, unsigned int bytesBeingSent, bool done, SystemAddress targetSystem)
00100     {
00101         (void) fileName;
00102         (void) fileLengthBytes;
00103         (void) offset;
00104         (void) bytesBeingSent;
00105         (void) done;
00106         (void) targetSystem;
00107     }
00108 
00110     virtual void OnFilePushesComplete( SystemAddress systemAddress )
00111     {
00112         (void) systemAddress;
00113     }
00114 
00116     virtual void OnSendAborted( SystemAddress systemAddress )
00117     {
00118         (void) systemAddress;
00119     }
00120 };
00121 
00123 class RAK_DLL_EXPORT FLP_Printf : public FileListProgress
00124 {
00125 public:
00126     // GetInstance() and DestroyInstance(instance*)
00127     STATIC_FACTORY_DECLARATIONS(FLP_Printf)
00128 
00129     FLP_Printf() {}
00130     virtual ~FLP_Printf() {}
00131 
00133     virtual void OnAddFilesFromDirectoryStarted(FileList *fileList, char *dir);
00134 
00136     virtual void OnDirectory(FileList *fileList, char *dir, unsigned int directoriesRemaining);
00137 
00139     virtual void OnFilePushesComplete( SystemAddress systemAddress );
00140 
00142     virtual void OnSendAborted( SystemAddress systemAddress );
00143 };
00144 
00145 class RAK_DLL_EXPORT FileList
00146 {
00147 public:
00148     // GetInstance() and DestroyInstance(instance*)
00149     STATIC_FACTORY_DECLARATIONS(FileList)
00150 
00151     FileList();
00152     ~FileList();
00160     void AddFilesFromDirectory(const char *applicationDirectory, const char *subDirectory, bool writeHash, bool writeData, bool recursive, FileListNodeContext context);
00161 
00163     void Clear(void);
00164 
00166     void Serialize(RakNet::BitStream *outBitStream);
00167 
00169     bool Deserialize(RakNet::BitStream *inBitStream);
00170 
00178     void ListMissingOrChangedFiles(const char *applicationDirectory, FileList *missingOrChangedFiles, bool alwaysWriteHash, bool neverWriteHash);
00179 
00187     void GetDeltaToCurrent(FileList *input, FileList *output, const char *dirSubset, const char *remoteSubdir);
00188 
00194     void PopulateDataFromDisk(const char *applicationDirectory, bool writeFileData, bool writeFileHash, bool removeUnknownFiles);
00195 
00198     void FlagFilesAsReferences(void);
00199 
00202     void WriteDataToDisk(const char *applicationDirectory);
00203 
00213     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);
00214 
00219     void AddFile(const char *filepath, const char *filename, FileListNodeContext context);
00220 
00223     void DeleteFiles(const char *applicationDirectory);
00224 
00227     void AddCallback(FileListProgress *cb);
00228 
00231     void RemoveCallback(FileListProgress *cb);
00232 
00234     void ClearCallbacks(void);
00235 
00238     void GetCallbacks(DataStructures::List<FileListProgress*> &callbacks);
00239 
00240     // Here so you can read it, but don't modify it
00241     DataStructures::List<FileListNode> fileList;
00242 
00243     static bool FixEndingSlash(char *str);
00244 protected:
00245     DataStructures::List<FileListProgress*> fileListProgressCallbacks;
00246 };
00247 
00248 } // namespace RakNet
00249 
00250 #ifdef _MSC_VER
00251 #pragma warning( pop )
00252 #endif
00253 
00254 #endif
00255 
00256 #endif // _RAKNET_SUPPORT_FileOperations

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