Game Development Reference
In-Depth Information
14. Check if such a ile exists in the archive:
bool FileExists( const std::string& FileName ) const
{ return ( GetFileIdx( FileName ) > -1 ); }
…
15. The following code is the
sFileInfo
structure mentioned in the preceding point,
that deines where a ile is located inside a
.zip
archive:
struct sFileInfo
{
16. First, we need an offset to the ile data inside the archive:
uint64 FOffset;
17. Then we need a size of the uncompressed ile:
uint64 FSize;
18. And a size of the compressed ile, to let the
zlib
library know when to stop decoding:
uint64 FCompressedSize;
19. Don't forget a pointer to the compressed data itself:
void* FSourceData;
};
…
};
We do not provide the complete source for the
ArchiveReader
class, however, do
encourage you to look into the accompanying source code. The second essential function,
the
ExtractSingleFile()
, is presented in the following recipe.
How it works...
We use the
ArchiveReader
class to write the
ArchiveMountPoint
that provides
seamless access to the contents of a
.zip
ile:
class ArchiveMountPoint: public iMountPoint
{
public:
ArchiveMountPoint( const clPtr<ArchiveReader>& R );
Create a reader interface to access the content of the archive:
virtual clPtr<iRawFile> CreateReader(
const std::string& VirtualName ) const
{