Game Development Reference
In-Depth Information
8. Iterate through all the iles in this archive:
for ( uLong i = 0; i < gi.number_entry; i++ )
{
char filename_inzip[256];
unz_file_info64 file_info;
err = unzGetCurrentFileInfo64( uf, &file_info,
filename_inzip, sizeof( filename_inzip ),
NULL, 0, NULL, 0 );
if ( err != UNZ_OK ) { break; }
if ( ( i + 1 ) < gi.number_entry )
{
err = unzGoToNextFile( uf );
}
9. Store the encountered ilenames in a vector of our own structures:
sFileInfo Info;
std::string TheName = Arch_FixFileName(filename_inzip);
Info.FCompressedSize = file_info.compressed_size;
Info.FSize = file_info.uncompressed_size;
FFileInfos.push_back( Info );
FFileNames.push_back( TheName );
}
unzClose( uf );
return true;
}
10. The array of sFileInfo structures is stored in the ArchiveReader instances:
class ArchiveReader: public iObject
{
public:
ArchiveReader();
virtual ~ArchiveReader();
11. Assign the source stream and enumerate the iles:
bool OpenArchive( const clPtr<iIStream>& Source );
12. Extract a single ile from the archive into the FOut stream. This means we can extract
compressed iles directly into the memory:
bool ExtractSingleFile( const std::string& FName,
const std::string& Password,
const clPtr<iOStream>& FOut );
13. Free everything and optionally close the source stream:
bool CloseArchive();
 
Search WWH ::




Custom Search