www.pudn.com > GameEngine_src.rar > CEPKFile.h
// CEPKFile.h: interface for the CEPKFile class. // ////////////////////////////////////////////////////////////////////// #ifndef CEPKFile_h #define CEPKFile_h #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "CHashTable.h" #includetypedef unsigned char BYTE; typedef unsigned long DWORD; const int EPK = 0x454b; enum EPK_OPEN_TYPE { EPK_OUT, EPK_IN, EPK_CREATE, EPK_NONE, }; struct EPKFILEHEADER { int epkType; //文件类型EPK int epkNumOfFile; //文件中所含的文件数目 int epkHashSize; //哈希表最大元素个数 int epkOffBits; //从文件头到数据区的偏移 DWORD epkSize; //整个文件的大小 DWORD epkMaxFileSize; //包中最大的文件长度 DWORD res1; //保留 DWORD res2; //保留 }; struct FILEINFO { FILEINFO(); ~FILEINFO(); FILEINFO( const FILEINFO& fileinfo ); void SetFileName( const char *filename ); FILEINFO &operator = ( const FILEINFO& fileinfo ); int operator % ( int i ) const; bool operator == ( const FILEINFO& fileinfo ); char m_szFileName[32]; int m_iFilePos; DWORD m_iFileSize; }; /////////////////////////////////////////////////////////////////////// //CEPKFile类,描述EPK文件. //负责打开,插入,查找,关闭EPK文件. // /////////////////////////////////////////////////////////////////////// class CEPKFile { public: CEPKFile(); ~CEPKFile(); bool Open( char *szFileName, EPK_OPEN_TYPE opentype ); void Close(); bool Write( char *szFileName ); BYTE *Read( const char *szFileName, int *pFileSize ); BYTE *Read( const char *szFileName ) { return Read( szFileName, NULL ); } bool GetFileList( FILEINFO **ppFileInfo, int *pNumFile ); bool SetBuffer( int bufsize ); private: DWORD GetFileSize( FILE *fp ); int GetFileNameWithoutPath( const char *namein, char * nameout, int size ); private: CHashTable m_hashtable; EPK_OPEN_TYPE m_opentype; EPKFILEHEADER m_fileheader; FILE *m_pfile; BYTE *m_buffer; int m_bufsize; }; #endif