diff options
author | Shauren <shauren.trinity@gmail.com> | 2019-06-06 16:48:21 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2019-06-08 17:09:24 +0200 |
commit | fc330fd8ff0115804d9c4b53a1f810c00dd63de9 (patch) | |
tree | cfa10998fed66779834bf0b7a9b8b799d33d91d4 /dep/CascLib/src/common/RootHandler.h | |
parent | 82c7b6c5688495d90c4ee5995a4ff74039348296 (diff) |
Dep/CascLib: Update to ladislav-zezula/CascLib@a1197edf0b3bd4d52c3f39be7fa7b44bb0b98012
Diffstat (limited to 'dep/CascLib/src/common/RootHandler.h')
-rw-r--r-- | dep/CascLib/src/common/RootHandler.h | 149 |
1 files changed, 82 insertions, 67 deletions
diff --git a/dep/CascLib/src/common/RootHandler.h b/dep/CascLib/src/common/RootHandler.h index d1b66e501d8..4e56650b034 100644 --- a/dep/CascLib/src/common/RootHandler.h +++ b/dep/CascLib/src/common/RootHandler.h @@ -15,82 +15,97 @@ // Defines #define CASC_MNDX_ROOT_SIGNATURE 0x58444E4D // 'MNDX' +#define CASC_TVFS_ROOT_SIGNATURE 0x53465654 // 'TVFS' #define CASC_DIABLO3_ROOT_SIGNATURE 0x8007D0C4 -#define CASC_OVERWATCH_ROOT_SIGNATURE 0x35444D23 // '#MD5' +#define CASC_WOW82_ROOT_SIGNATURE 0x4D465354 // 'TSFM', WoW since 8.2 -#define ROOT_FLAG_HAS_NAMES 0x00000001 // The root file contains file names - -#define DUMP_LEVEL_ROOT_FILE 1 // Dump root file -#define DUMP_LEVEL_ENCODING_FILE 2 // Dump root file + encoding file -#define DUMP_LEVEL_INDEX_ENTRIES 3 // Dump root file + encoding file + index entries +#define DUMP_LEVEL_ROOT_FILE 1 // Dump root file +#define DUMP_LEVEL_ENCODING_FILE 2 // Dump root file + encoding file +#define DUMP_LEVEL_INDEX_ENTRIES 3 // Dump root file + encoding file + index entries //----------------------------------------------------------------------------- -// Root file function prototypes - -typedef int (*ROOT_INSERT)( - struct TRootHandler * pRootHandler, // Pointer to an initialized root handler - const char * szFileName, // Pointer to the file name - LPBYTE pbEncodingKey // Pointer to the encoding key of the file name - ); - -typedef LPBYTE (*ROOT_SEARCH)( - struct TRootHandler * pRootHandler, // Pointer to an initialized root handler - struct _TCascSearch * pSearch, // Pointer to the initialized search structure - PDWORD PtrFileSize, // Pointer to receive file size (optional) - PDWORD PtrLocaleFlags, // Pointer to receive locale flags (optional) - PDWORD PtrFileDataId // Pointer to FileDataID (optional) - ); - -typedef void (*ROOT_ENDSEARCH)( - struct TRootHandler * pRootHandler, // Pointer to an initialized root handler - struct _TCascSearch * pSearch // Pointer to the initialized search structure - ); - -typedef LPBYTE (*ROOT_GETKEY)( - struct TRootHandler * pRootHandler, // Pointer to an initialized root handler - const char * szFileName // Pointer to the name of a file - ); - -typedef void (*ROOT_DUMP)( - struct _TCascStorage * hs, // Pointer to the open storage - TDumpContext * dc, // Opened dump context - LPBYTE pbRootHandler, // Pointer to the loaded ROOT file - DWORD cbRootHandler, // Length of the loaded ROOT file - const TCHAR * szListFile, - int nDumpLevel - ); - -typedef void (*ROOT_CLOSE)( - struct TRootHandler * pRootHandler // Pointer to an initialized root handler - ); - -typedef DWORD(*ROOT_GETFILEID)( -struct TRootHandler * pRootHandler, // Pointer to an initialized root handler - const char * szFileName // Pointer to the name of a file - ); +// Class for generic root handler struct TRootHandler { - ROOT_INSERT Insert; // Inserts an existing file name - ROOT_SEARCH Search; // Performs the root file search - ROOT_ENDSEARCH EndSearch; // Performs cleanup after searching - ROOT_GETKEY GetKey; // Retrieves encoding key for a file name - ROOT_DUMP Dump; - ROOT_CLOSE Close; // Closing the root file - ROOT_GETFILEID GetFileId; // Returns File Id for a given Filename - - DWORD dwRootFlags; // Root flags - see the ROOT_FLAG_XXX + public: + + TRootHandler() + { + dwFeatures = 0; + } + + virtual ~TRootHandler() + {} + + // Inserts new file name to the root handler + // szFileName - Pointer to the file name + // pCKeyEntry - Pointer to the CASC_CKEY_ENTRY for the file + virtual int Insert(const char * /* szFileName */, PCASC_CKEY_ENTRY /* pCKeyEntry */) + { + return ERROR_NOT_SUPPORTED; + } + + // Searches the file by file name + // hs - Pointer to the storage structure + // szFileName - Pointer to the file name + virtual PCASC_CKEY_ENTRY GetFile(struct TCascStorage * /* hs */, const char * /* szFileName */) + { + return NULL; + } + + // Searches the file by file data id + // hs - Pointer to the storage structure + // FileDataId - File data id + virtual PCASC_CKEY_ENTRY GetFile(struct TCascStorage * /* hs */, DWORD /* FileDataId */) + { + return NULL; + } + + // Performs find-next-file operation + // pSearch - Pointer to the initialized search structure + // pFindData - Pointer to output structure that will contain the information + virtual PCASC_CKEY_ENTRY Search(struct TCascSearch * /* pSearch */, struct _CASC_FIND_DATA * /* pFindData */) + { + return NULL; + } + + // Returns advanced info from the root file entry. + // pCKeyEntry - CKey/EKey, depending on which type the root handler provides + // pFileInfo - Pointer to CASC_FILE_FULL_INFO structure + virtual bool GetInfo(PCASC_CKEY_ENTRY /* pCKeyEntry */, struct _CASC_FILE_FULL_INFO * /* pFileInfo */) + { + return false; + } + + DWORD GetFeatures() + { + return dwFeatures; + } + + protected: + + DWORD dwFeatures; // CASC features. See CASC_FEATURE_XXX }; //----------------------------------------------------------------------------- -// Public functions - -int RootHandler_Insert(TRootHandler * pRootHandler, const char * szFileName, LPBYTE pbEncodingKey); -LPBYTE RootHandler_Search(TRootHandler * pRootHandler, struct _TCascSearch * pSearch, PDWORD PtrFileSize, PDWORD PtrLocaleFlags, PDWORD PtrFileDataId); -void RootHandler_EndSearch(TRootHandler * pRootHandler, struct _TCascSearch * pSearch); -LPBYTE RootHandler_GetKey(TRootHandler * pRootHandler, const char * szFileName); -void RootHandler_Dump(struct _TCascStorage * hs, LPBYTE pbRootHandler, DWORD cbRootHandler, const TCHAR * szNameFormat, const TCHAR * szListFile, int nDumpLevel); -void RootHandler_Close(TRootHandler * pRootHandler); -DWORD RootHandler_GetFileId(TRootHandler * pRootHandler, const char * szFileName); +// Class for root handler that has basic mapping of FileName -> CASC_FILE_NODE + +struct TFileTreeRoot : public TRootHandler +{ + TFileTreeRoot(DWORD FileTreeFlags); + virtual ~TFileTreeRoot(); + + int Insert(const char * szFileName, PCASC_CKEY_ENTRY pCKeyEntry); + + PCASC_CKEY_ENTRY GetFile(struct TCascStorage * hs, const char * szFileName); + PCASC_CKEY_ENTRY GetFile(struct TCascStorage * hs, DWORD FileDataId); + PCASC_CKEY_ENTRY Search(struct TCascSearch * pSearch, struct _CASC_FIND_DATA * pFindData); + bool GetInfo(PCASC_CKEY_ENTRY pCKeyEntry, struct _CASC_FILE_FULL_INFO * pFileInfo); + + protected: + + CASC_FILE_TREE FileTree; +}; #endif // __ROOT_HANDLER_H__ |