From dc30ffd8b3f98c0f8bb97782df10ffa891f6d192 Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Wed, 20 Feb 2013 00:30:48 -0500 Subject: [PATCH] Updated IFileSystem. --HG-- branch : tf2beta --- public/filesystem.h | 43 +++++++++++++++++++++++------------- public/filesystem_passthru.h | 24 +++++++------------- 2 files changed, 36 insertions(+), 31 deletions(-) diff --git a/public/filesystem.h b/public/filesystem.h index d14e0945..aa14351c 100644 --- a/public/filesystem.h +++ b/public/filesystem.h @@ -340,6 +340,29 @@ struct FileAsyncRequest_t FSAllocFunc_t pfnAlloc; // custom allocator. can be null. not compatible with FSASYNC_FLAGS_FREEDATAPTR }; +struct MD5Value_t +{ + unsigned char bits[16]; +}; + +struct FileHash_t +{ + int m_eFileHashType; + CRC32_t m_crcIOSequence; + MD5Value_t m_md5contents; + int m_cbFileLen; + int m_PackFileID; + int m_nPackFileNumber; +}; + +class CUnverifiedFileHash +{ +public: + char m_PathID[MAX_PATH]; + char m_Filename[MAX_PATH]; + int m_nFileFraction; + FileHash_t m_FileHash; +}; class CUnverifiedCRCFile { @@ -349,7 +372,6 @@ public: CRC32_t m_CRC; }; - // Spew flags for SetWhitelistSpewFlags (set with the fs_whitelist_spew_flags cvar). // Update the comment for the fs_whitelist_spew_flags cvar if you change these. #define WHITELIST_SPEW_WHILE_LOADING 0x0001 // list files as they are added to the CRC tracker @@ -403,7 +425,7 @@ public: // Main file system interface //----------------------------------------------------------------------------- -#define FILESYSTEM_INTERFACE_VERSION "VFileSystem020" +#define FILESYSTEM_INTERFACE_VERSION "VFileSystem022" abstract_class IFileSystem : public IAppSystem, public IBaseFileSystem { @@ -725,24 +747,16 @@ public: // As the server loads whitelists when it transitions maps, it calls this to calculate CRCs for any files marked // with check_crc. Then it calls CheckCachedFileCRC later when it gets client requests to verify CRCs. virtual void CacheFileCRCs( const char *pPathname, ECacheCRCType eType, IFileList *pFilter ) = 0; - virtual EFileCRCStatus CheckCachedFileCRC( const char *pPathID, const char *pRelativeFilename, CRC32_t *pCRC ) = 0; + virtual EFileCRCStatus CheckCachedFileHash( const char *pPathID, const char *pRelativeFilename, FileHash_t *pFileHash ) = 0; - virtual void CacheFileMD5s( const char *pPathname, ECacheCRCType eType, IFileList *pFilter ) = 0; - - // Last param is an MD5Value_t pointer. - virtual EFileCRCStatus CheckCachedFileMD5( const char *pPathID, const char *pRelativeFilename, void *pMD5 ) = 0; - // Fills in the list of files that have been loaded off disk and have not been verified. // Returns the number of files filled in (between 0 and nMaxFiles). // // This also removes any files it's returning from the unverified CRC list, so they won't be // returned from here again. // The client sends batches of these to the server to verify. - virtual int GetUnverifiedCRCFiles( CUnverifiedCRCFile *pFiles, int nMaxFiles ) = 0; + virtual int GetUnverifiedFileHashes( CUnverifiedFileHash *pFiles, int nMaxFiles ) = 0; - // First param is a CUnverifiedMD5File pointer. - virtual int GetUnverifiedMD5Files( void *pFiles, int nMaxFiles ) = 0; - // Control debug message output. // Pass a combination of WHITELIST_SPEW_ flags. virtual int GetWhitelistSpewFlags() = 0; @@ -763,9 +777,8 @@ public: virtual bool RegisterMemoryFile( void *pFile, void **ppExistingFileWithRef ) = 0; virtual void UnregisterMemoryFile( void *pFile ) = 0; - virtual void AddVPKFile( const char *pBasename, SearchPathAdd_t addType ) = 0; - virtual void RemoveVPKFile( const char *pBasename ) = 0; - virtual void GetVPKFileNames( CUtlVector &destVector ) = 0; + virtual void CacheAllVPKFileHashes(bool bCacheAllVPKHashes, bool bRecalculateAndCheckHashes) = 0; + virtual bool CheckVPKFileHash(int PackFileID, int nPackFileNumber, int nFileFraction, MD5Value_t &md5Value) = 0; }; //----------------------------------------------------------------------------- diff --git a/public/filesystem_passthru.h b/public/filesystem_passthru.h index de1b2bbe..a89623dd 100644 --- a/public/filesystem_passthru.h +++ b/public/filesystem_passthru.h @@ -223,16 +223,10 @@ public: { m_pFileSystemPassThru->MarkAllCRCsUnverified(); } virtual void CacheFileCRCs( const char *pPathname, ECacheCRCType eType, IFileList *pFilter ) { return m_pFileSystemPassThru->CacheFileCRCs( pPathname, eType, pFilter ); } - virtual void CacheFileMD5s( const char *pPathname, ECacheCRCType eType, IFileList *pFilter ) - { return m_pFileSystemPassThru->CacheFileMD5s( pPathname, eType, pFilter ); } - virtual EFileCRCStatus CheckCachedFileCRC( const char *pPathID, const char *pRelativeFilename, CRC32_t *pCRC ) - { return m_pFileSystemPassThru->CheckCachedFileCRC( pPathID, pRelativeFilename, pCRC ); } - virtual EFileCRCStatus CheckCachedFileMD5( const char *pPathID, const char *pRelativeFilename, void *pMD5 ) - { return m_pFileSystemPassThru->CheckCachedFileMD5( pPathID, pRelativeFilename, pMD5 ); } - virtual int GetUnverifiedCRCFiles( CUnverifiedCRCFile *pFiles, int nMaxFiles ) - { return m_pFileSystemPassThru->GetUnverifiedCRCFiles( pFiles, nMaxFiles ); } - virtual int GetUnverifiedMD5Files( void *pFiles, int nMaxFiles ) - { return m_pFileSystemPassThru->GetUnverifiedMD5Files( pFiles, nMaxFiles ); } + virtual EFileCRCStatus CheckCachedFileHash( const char *pPathID, const char *pRelativeFilename, FileHash_t *pFileHash ) + { return m_pFileSystemPassThru->CheckCachedFileHash( pPathID, pRelativeFilename, pFileHash ); } + virtual int GetUnverifiedFileHashes( CUnverifiedFileHash *pFiles, int nMaxFiles ) + { return m_pFileSystemPassThru->GetUnverifiedFileHashes( pFiles, nMaxFiles ); } virtual int GetWhitelistSpewFlags() { return m_pFileSystemPassThru->GetWhitelistSpewFlags(); } virtual void SetWhitelistSpewFlags( int spewFlags ) @@ -258,12 +252,10 @@ public: virtual void UnregisterMemoryFile( void *pFile ) { m_pFileSystemPassThru->UnregisterMemoryFile( pFile ); } - virtual void AddVPKFile( const char *pBasename, SearchPathAdd_t addType ) - { m_pFileSystemPassThru->AddVPKFile( pBasename, addType ); } - virtual void RemoveVPKFile( const char *pBasename ) - { m_pFileSystemPassThru->RemoveVPKFile( pBasename ); } - virtual void GetVPKFileNames( CUtlVector &destVector ) - { m_pFileSystemPassThru->GetVPKFileNames( destVector ); } + virtual void CacheAllVPKFileHashes(bool bCacheAllVPKHashes, bool bRecalculateAndCheckHashes) + { m_pFileSystemPassThru->CacheAllVPKFileHashes(bCacheAllVPKHashes, bRecalculateAndCheckHashes); } + virtual bool CheckVPKFileHash(int PackFileID, int nPackFileNumber, int nFileFraction, MD5Value_t &md5Value) + { m_pFileSystemPassThru->CheckVPKFileHash(PackFileID, nPackFileNumber, nFileFraction, md5Value); } protected: IFileSystem *m_pFileSystemPassThru;