Decompressing files from the .zip archives
We have the Enumerate_ZIP()
function to iterate through individual files inside a .zip
archive, and now it is time to extract its contents.
Getting ready
This code uses the same set of fopen()
-like functions from the previous recipe.
How to do it...
The following helper function does the job of file extraction and is used in the
ArchiveReader::ExtractSingleFile()
method:int ExtractCurrentFile_ZIP( unzFile uf,const char* password, const clPtr<iOStream>& fout ) { char filename_inzip[256]; int err = UNZ_OK; void* buf; uInt size_buf; unz_file_info64 file_info; err = unzGetCurrentFileInfo64( uf, &file_info,filename_inzip, sizeof( filename_inzip ),NULL, 0, NULL, 0 ); if ( err != UNZ_OK ) { return err; } uint64_t file_size = ( uint64_t )file_info.uncompressed_size; uint64_t total_bytes = 0; unsigned char _buf[WRITEBUFFERSIZE]; size_buf = WRITEBUFFERSIZE; buf = ( void* )_buf; if ( buf == NULL ) { return UNZ_INTERNALERROR...