Archive.h
Go to the documentation of this file.00001 00015 #ifndef __Archive_H__ 00016 #define __Archive_H__ 00017 00018 // Includes 00019 #include "StringId.h" 00020 #include "Array.h" 00021 #include "HashTable.h" 00022 #include "HashTableKey_StringId.h" 00023 00024 // Forward declares 00025 class StaticBuffer; 00026 class Platform_FileSystem_File; 00027 class ArchiveFile; 00028 class ArchiveDirectory; 00029 class Filename; 00030 00031 00032 // Archive 00033 class Archive 00034 { 00035 public: 00040 Archive( 00041 const void* memoryBuffer, 00042 int size 00043 ); 00044 00049 Archive( 00050 const Filename& filename 00051 ); 00052 00056 ~Archive(); 00057 00064 ArchiveFile* GetFile( 00065 const Filename& filename 00066 ) const; 00067 00068 00069 const ArchiveDirectory* GetDirectory(const Filename& path) const; 00070 00071 const ArchiveDirectory* GetRootDirectory() const; 00072 00073 00074 private: 00075 struct DirectoryEntry; 00076 00077 void ReadDirectory(DirectoryEntry* directoryEntry,char* parentPath); 00078 00079 private: 00080 StaticBuffer* archiveBuffer_; 00081 Platform_FileSystem_File* archiveFile_; 00082 00083 struct FileEntry 00084 { 00085 StringId filename; 00086 int offset; 00087 int size; 00088 }; 00089 00090 struct DirectoryEntry 00091 { 00092 StringId name; 00093 Array<DirectoryEntry> subDirectories; 00094 Array<FileEntry> files; 00095 }; 00096 00097 DirectoryEntry root_; 00098 00099 HashTable<HashTableKey_StringId,FileEntry> files_; 00100 HashTable<HashTableKey_StringId,ArchiveDirectory*> directories_; 00101 }; 00102 00103 00104 #endif /* __Archive_H__ */
Reproduction/republishing of any material on this site without permission is strictly prohibited.
