Game Development Reference
In-Depth Information
{
int err = UNZ_OK;
LString ZipName = FName;
std::replace ( ZipName.begin(), ZipName.end(), '\\', '/' );
clPtr<iIStream> TheSource = FSourceFile;
TheSource->Seek(0);
5.
Decompress the data through the following code:
zlib_filefunc64_def ffunc;
fill_functions( FSourceFile.GetInternalPtr(), &ffunc );
unzFile uf = unzOpen2_64( "", &ffunc );
if ( unzLocateFile( uf, ZipName.c_str(), 0) != UNZ_OK )
{
return false;
}
err = ExtractCurrentFile_ZIP( uf,
Password.empty() ? NULL : Password.c_str(), FOut );
unzClose( uf );
return ( err == UNZ_OK );
}
How it works...
The ExtractSingleFile() method uses the zlib and MiniZIP libraries. In the
accompanying material, we have included the libcompress.c and libcompress.h
iles that contain the amalgamated zlib , MiniZIP, and libbzip2 sources.
The 2_MountPoints example contains the test.cpp ile with the code to iterate an
archive ile:
clPtr<RawFile> File = new RawFile();
File->Open( "test.zip", "" );
clPtr<ArchiveReader> a = new ArchiveReader();
a->OpenArchive( new FileMapper(File) );
The ArchiveReader instance contains all the information about the contents of the test.
zip ile.
Loading resources asynchronously
The preface of this topic tells us we are going to develop an asynchronous resources loading
system in this chapter. We have completed all of the preparations for this. We are now
equipped with secure memory management, task queues, and inally, the FileSystem
abstraction with archive ile support.
 
Search WWH ::




Custom Search