int unz_exists(const char *filename) { if (unzLocateFile(gamezip, filename, 1) == UNZ_OK) { foundzip = gamezip; return 1; } else if (unzLocateFile(basezip, filename, 1) == UNZ_OK) { foundzip = basezip; return 1; } return 0; }
bool zip_extract_onefile(const char* zip_filename, const char* filename , const char* save_filename) { // 解压先使用 zipOpen64 来打开一个 ZIP 文件 unzFile uf = unzOpen64(zip_filename); // // 需要先使用 unzGetGlobalInfo64 来取得该文件的一些信息,来了解这个压缩包里一共包含了多少个文件,等等。 // unz_global_info64 gi; // // if (unzGetGlobalInfo64(uf, &gi) != UNZ_OK) { // return false; // } // 尝试zip文件中找到该文件szFileName。 int err = UNZ_OK; if (unzLocateFile(uf, filename, CASESENSITIVITY) != UNZ_OK) { printf("file %s not found in the zipfile\n", filename); return false; } if (!zip_extract_currentfile(uf, save_filename)) { return false; } unzClose(uf); return true; }
bool ComicBookZIP::TestPassword() { int retcode; unzFile ZipFile; ZipFile = unzOpen(filename.ToAscii()); bool retval; if (!ZipFile) { throw ArchiveException(filename, wxT("Could not open the file.")); } if((retcode = unzLocateFile(ZipFile, Filenames->Item(0).ToAscii(), 0)) != UNZ_OK) { unzClose(ZipFile); throw ArchiveException(filename, ArchiveError(retcode)); } if (password) retcode = unzOpenCurrentFilePassword(ZipFile, password); else retcode = unzOpenCurrentFile(ZipFile); if (retcode != UNZ_OK) { unzClose(ZipFile); throw ArchiveException(filename, ArchiveError(retcode)); } char testByte; if(unzReadCurrentFile(ZipFile, &testByte, 1) == Z_DATA_ERROR) // if the password is wrong retval = false; else retval = true; unzCloseCurrentFile(ZipFile); unzClose(ZipFile); return retval; }
idStr CZipFile::LoadTextFile(const idStr& fileName) { int result = unzLocateFile(_handle, fileName.c_str(), 0); if (result != UNZ_OK) return ""; unz_file_info info; unzGetCurrentFileInfo(_handle, &info, NULL, 0, NULL, 0, NULL, 0); unsigned long fileSize = info.uncompressed_size; int openResult = unzOpenCurrentFile(_handle); idStr returnValue; if (openResult == UNZ_OK) { char* buffer = new char[fileSize + 1]; // Read and null-terminate the string unzReadCurrentFile(_handle, buffer, fileSize); buffer[fileSize] = '\0'; returnValue = buffer; delete[] buffer; } unzCloseCurrentFile(_handle); return returnValue; }
const byte *JARInputSource::openStream() { if (stream != null) throw InputSourceException(StringBuffer("openStream(): source stream already opened: '")+baseLocation+"'"); MemoryFile *mf = new MemoryFile; mf->stream = sharedIS->getStream(); mf->length = sharedIS->length(); zlib_filefunc_def zlib_ff; fill_mem_filefunc(&zlib_ff, mf); unzFile fid = unzOpen2(null, &zlib_ff); if (fid == 0) throw InputSourceException(StringBuffer("Can't locate file in JAR content: '")+inJarLocation+"'"); int ret = unzLocateFile(fid, inJarLocation->getChars(), 0); if (ret != UNZ_OK) throw InputSourceException(StringBuffer("Can't locate file in JAR content: '")+inJarLocation+"'"); unz_file_info file_info; ret = unzGetCurrentFileInfo(fid, &file_info, null, 0, null, 0, null, 0); if (ret != UNZ_OK) throw InputSourceException(StringBuffer("Can't retrieve current file in JAR content: '")+inJarLocation+"'"); len = file_info.uncompressed_size; stream = new byte[len]; ret = unzOpenCurrentFile(fid); if (ret != UNZ_OK) throw InputSourceException(StringBuffer("Can't open current file in JAR content: '")+inJarLocation+"'"); ret = unzReadCurrentFile(fid, stream, len); if (ret <= 0) throw InputSourceException(StringBuffer("Can't read current file in JAR content: '")+inJarLocation+"' ("+SString(ret)+")"); ret = unzCloseCurrentFile(fid); if (ret == UNZ_CRCERROR) throw InputSourceException(StringBuffer("Bad JAR file CRC")); ret = unzClose(fid); return stream; };
bool ZipArchive::extract(std::string from, std::string where, std::vector<std::string> what) { unzFile archive = unzOpen(from.c_str()); auto onExit = vstd::makeScopeGuard([&]() { unzClose(archive); }); for (std::string & file : what) { if (unzLocateFile(archive, file.c_str(), 1) != UNZ_OK) return false; std::string fullName = where + '/' + file; std::string fullPath = fullName.substr(0, fullName.find_last_of("/")); boost::filesystem::create_directories(fullPath); // directory. No file to extract // TODO: better way to detect directory? Probably check return value of unzOpenCurrentFile? if (boost::algorithm::ends_with(file, "/")) continue; std::ofstream destFile(fullName, std::ofstream::binary); if (!destFile.good()) return false; if (!extractCurrent(archive, destFile)) return false; } return true; }
extern "C" bool ArchGetFileW(HZIP hZip,WCHAR *pstrFile,byte **lpMem,int *dwSize) { bool r=false; ZIPDECOMPRESSION *p=(ZIPDECOMPRESSION *)hZip; if ((hZip) && (p->bHandleType == HT_DECOMPRESSOR) && (pstrFile) && (lpMem) && (dwSize)) { LPCSTR pFileName=UnicodeToOemEx(pstrFile,-1); unzGoToFirstFile(p->hZip); p->bExctractToMem=true; if (unzLocateFile(p->hZip,pFileName,CASESENSITIVITY) == UNZ_OK) r=(ExtractCurrentFile(hZip,true) > -1) ? true : false; else { ArchSetLastError(ARCH_FILE_NOT_FOUND); r=false; } MemFree((void*)pFileName); if (r) { *lpMem=(byte*)p->lpMem; *dwSize=p->dwSize; } } else ArchSetLastError(ARCH_INVALID_PARAMETER); return r; }
BITMAP *emudx_bitmap(emudx_file dat, int nb) { char name[10]; int err; BITMAP *bmp; PALETTE pal; sprintf(name,"%03d.png",nb); err = unzLocateFile(dat,name,2); if(err!=UNZ_OK){ print_debug("emudx: not found %s.\n",name); unzClose(dat); return NULL; // Fail: File not in zip } err = unzOpenCurrentFile(dat); if(err!=UNZ_OK){ print_debug("emudx: unzOpenCurrentFile(): Error #%d\n",err); unzCloseCurrentFile(dat); // Is this needed when open failed? unzClose(dat); return NULL; // Fail: Something internal } bmp = load_png_from_zip(dat,pal); return bmp; }
/** * Load a file from the ZOMG file. * @param filename Filename to load from the ZOMG file. * @param buf Buffer to store the file in. * @param len Length of the buffer. * @return Length of file loaded, or negative number on error. */ int ZomgPrivate::loadFromZomg(const char *filename, void *buf, int len) { if (q->m_mode != ZomgBase::ZOMG_LOAD || !this->unz) return -EBADF; // Locate the file in the ZOMG file. int ret = unzLocateFile(this->unz, filename, 2); if (ret != UNZ_OK) { // File not found. return -ENOENT; } // Open the current file. ret = unzOpenCurrentFile(this->unz); if (ret != UNZ_OK) { // Error opening the current file. return -EIO; } // Read the file. ret = unzReadCurrentFile(this->unz, buf, len); unzCloseCurrentFile(this->unz); // TODO: Check the return value! // Return the number of bytes read. return ret; }
dmz::Boolean dmz::ReaderZip::open_file (const String &FileName) { Boolean result (False); if (_state.zf) { close_file (); result = _state.zip_error (unzLocateFile ( _state.zf, FileName.get_buffer (), 1)); // Case sensitive if (result) { result = _state.zip_error (unzOpenCurrentFile (_state.zf)); if (result) { _state.fileName = FileName; } } } else { _state.error.flush () << "Zip archive not open."; } return result; }
/****************************************************************************** *** Description *** Checks if a file exists in a zip file. *** *** Arguments *** zipName - Name of zip file *** fileName - Name of file insize zipfile to load *** *** Return *** 1 = file exists, 0 = non existing zip or file in zip does not exists *** failure. *** ******************************************************************************* */ int zipFileExists(const char* zipName, const char* fileName) { char name[256]; unzFile zip; if (fileName[0] == '*') { strcpy(name, zipName); name[strlen(zipName) - 3] = fileName[strlen(fileName) - 3]; name[strlen(zipName) - 2] = fileName[strlen(fileName) - 2]; name[strlen(zipName) - 1] = fileName[strlen(fileName) - 1]; } else { strcpy(name, fileName); } zip = unzOpen(zipName); if (!zip) { return 0; } if (unzLocateFile(zip, name, 2) == UNZ_END_OF_LIST_OF_FILE) { unzClose(zip); return 0; }else{ unzClose(zip); return 1; } }
unsigned char* CCZipFile::getFileData(const char *filename, unsigned long *filesize) { unsigned char *buffer = NULL; *filesize = 0; do { int ret = unzLocateFile(m_zipFile, filename, 1); CC_BREAK_IF(UNZ_OK != ret); std::string path; unz_file_info info; CC_BREAK_IF(UNZ_OK != getCurrentFileInfo(&path, &info)); ret = unzOpenCurrentFile(m_zipFile); CC_BREAK_IF(UNZ_OK != ret); buffer = new unsigned char[info.uncompressed_size]; int size = 0; size = unzReadCurrentFile(m_zipFile, buffer, info.uncompressed_size); CCAssert(size == 0 || size == (int)info.uncompressed_size, "the file size is wrong"); *filesize = info.uncompressed_size; unzCloseCurrentFile(m_zipFile); } while (0); return buffer; }
bool Extract(LPCTSTR szSrc, char** ppBuf, DWORD* pdwSize = NULL) throw() { if ( pdwSize ) *pdwSize = 0; *ppBuf = NULL; bool ret = false; if ( unzLocateFile( hArchive, CT2CA( szSrc ), 2 ) == UNZ_OK ) { unz_file_info fi = {}; if ( unzGetCurrentFileInfo( hArchive, &fi, NULL, NULL, NULL, NULL, NULL, NULL ) == UNZ_OK ) { if ( unzOpenCurrentFile( hArchive ) == UNZ_OK ) { if ( pdwSize ) *pdwSize = fi.uncompressed_size; *ppBuf = new char[ fi.uncompressed_size + 2 ]; if ( *ppBuf ) { ZeroMemory( *ppBuf, fi.uncompressed_size + 2 ); ret = ( unzReadCurrentFile( hArchive, *ppBuf, fi.uncompressed_size ) == (int)fi.uncompressed_size ); } unzCloseCurrentFile( hArchive ); } } } return ret; }
bool ApkFile::open(const std::string &path) { unzFile uf = unzOpen(path.c_str()); if (!uf) { LOGE("%s: Failed to open archive", path.c_str()); return false; } auto close_uf = util::finally([&]{ unzClose(uf); }); if (unzLocateFile(uf, "AndroidManifest.xml", nullptr) != UNZ_OK) { LOGE("%s: package does not contain AndroidManifest.xml", path.c_str()); return false; } std::vector<unsigned char> data; if (!read_to_memory(uf, &data)) { LOGE("%s: Failed to extract AndroidManifest.xml", path.c_str()); return false; } // Load AndroidManifest.xml and check package name return parse_manifest(data.data(), data.size()); }
bool ZipArchive::extract(boost::filesystem::path from, boost::filesystem::path where, std::vector<std::string> what) { unzFile archive = unzOpen2_64(from.c_str(), FileStream::GetMinizipFilefunc()); auto onExit = vstd::makeScopeGuard([&]() { unzClose(archive); }); for (const std::string & file : what) { if (unzLocateFile(archive, file.c_str(), 1) != UNZ_OK) return false; const boost::filesystem::path fullName = where / file; const boost::filesystem::path fullPath = fullName.parent_path(); boost::filesystem::create_directories(fullPath); // directory. No file to extract // TODO: better way to detect directory? Probably check return value of unzOpenCurrentFile? if (boost::algorithm::ends_with(file, "/")) continue; FileStream destFile(fullName, std::ios::out | std::ios::binary); if (!destFile.good()) return false; if (!extractCurrent(archive, destFile)) return false; } return true; }
zlib_FileResource::zlib_FileResource(const std::string & zipPath, const std::string & fileName) : m_ZipPath(zipPath), m_FileName(fileName) { unzFile zipFile = unzOpen(zipPath.c_str()); KeziaAssert(unzLocateFile(zipFile, fileName.c_str(), 0) == UNZ_OK); unz_file_info fileInfo; unzGetCurrentFileInfo(zipFile, &fileInfo, nullptr, 0, nullptr, 0, nullptr, 0); m_Data = new char[fileInfo.uncompressed_size + 1]; if(unzOpenCurrentFilePassword(zipFile, k_Password.c_str()) != UNZ_OK) { LOG("wrong password"); } m_DataSize = unzReadCurrentFile(zipFile, const_cast<char *>(m_Data), fileInfo.uncompressed_size); const_cast<char &>(m_Data[m_DataSize]) = '\0'; unzCloseCurrentFile(zipFile); unzClose(zipFile); }
static int readfromzip_cb(lua_State* L) { const char* zipname = luaL_checkstring(L, 1); const char* subname = luaL_checkstring(L, 2); int result = 0; unzFile zf = unzOpen(zipname); if (zf) { int i = unzLocateFile(zf, subname, 0); if (i == UNZ_OK) { unz_file_info fi; unzGetCurrentFileInfo(zf, &fi, NULL, 0, NULL, 0, NULL, 0); char* buffer = malloc(fi.uncompressed_size); if (buffer) { unzOpenCurrentFile(zf); i = unzReadCurrentFile(zf, buffer, fi.uncompressed_size); if (i == fi.uncompressed_size) { lua_pushlstring(L, buffer, fi.uncompressed_size); result = 1; } free(buffer); } } unzClose(zf); } return result; }
bool ArchiveReader::ExtractSingleFile( const std::string& FName, const std::string& Password, int* AbortFlag, float* Progress, const clPtr<iOStream>& FOut ) { int err = UNZ_OK; std::string ZipName = FName; std::replace( ZipName.begin(), ZipName.end(), '\\', '/' ); clPtr<iIStream> TheSource = FSourceFile; FSourceFile->Seek( 0 ); /// Decompress the data zlib_filefunc64_def ffunc; fill_functions( TheSource.GetInternalPtr(), &ffunc ); unzFile uf = unzOpen2_64( "", &ffunc ); if ( unzLocateFile( uf, ZipName.c_str(), 0/*CASESENSITIVITY - insensitive*/ ) != UNZ_OK ) { // WARNING: "File %s not found in the zipfile\n", FName.c_str() return false; } err = ExtractCurrentFile_ZIP( uf, Password.empty() ? NULL : Password.c_str(), AbortFlag, Progress, FOut ); unzClose( uf ); return ( err == UNZ_OK ); }
SeekableReadStream *ZipArchive::createReadStreamForMember(const String &name) const { if (unzLocateFile(_zipFile, name.c_str(), 2) != UNZ_OK) return 0; unz_file_info fileInfo; if (unzOpenCurrentFile(_zipFile) != UNZ_OK) return 0; if (unzGetCurrentFileInfo(_zipFile, &fileInfo, NULL, 0, NULL, 0, NULL, 0) != UNZ_OK) return 0; byte *buffer = (byte *)malloc(fileInfo.uncompressed_size); assert(buffer); if (unzReadCurrentFile(_zipFile, buffer, fileInfo.uncompressed_size) != (int)fileInfo.uncompressed_size) { free(buffer); return 0; } if (unzCloseCurrentFile(_zipFile) != UNZ_OK) { free(buffer); return 0; } return new MemoryReadStream(buffer, fileInfo.uncompressed_size, DisposeAfterUse::YES); // FIXME: instead of reading all into a memory stream, we could // instead create a new ZipStream class. But then we have to be // careful to handle the case where the client code opens multiple // files in the archive and tries to use them independently. }
bool CMinizip::Extract(LPCTSTR FileName, LPCTSTR DestPath, UINT BufSize) { USES_CONVERSION; if (unzLocateFile(m_ZipFile, T2CA(FileName), 0) != UNZ_OK) return(FALSE); if (unzOpenCurrentFile(m_ZipFile) != UNZ_OK) return(FALSE); CByteArray ba; ba.SetSize(BufSize); bool retc = FALSE; // assume failure TRY { CFile DestFile(DestPath, CFile::modeCreate | CFile::modeWrite); int BytesRead; while ((BytesRead = unzReadCurrentFile(m_ZipFile, ba.GetData(), BufSize)) > 0) { DestFile.Write(ba.GetData(), BytesRead); } if (!BytesRead) // if EOF retc = TRUE; // success provided current file closes OK } CATCH (CFileException, e) { e->ReportError(); } END_CATCH if (unzCloseCurrentFile(m_ZipFile) != UNZ_OK) // close fails if bad CRC return(FALSE); return(retc); }
bool ZipFile::LoadFile(const char* package, const char* file) { FileClose(); unzFile fp = unzOpen(package); if (!fp) return false; if (unzLocateFile(fp,file,0) != UNZ_OK) { unzClose(fp); return false; } if (unzOpenCurrentFile(fp) != UNZ_OK) { unzClose(fp); return false; } unz_file_info nfo; unzGetCurrentFileInfo(fp,&nfo,0,0,0,0,0,0); size = (long)nfo.uncompressed_size; data = new char[size]; unzReadCurrentFile(fp,data,size); unzCloseCurrentFile(fp); unzClose(fp); return true; }
bool UnzipFile::open() { if (d->filepath.isEmpty()) { PAINTFIELD_WARNING << "file path not specified"; return false; } if (d->archive->d->currentUnzipFile) { PAINTFIELD_WARNING << "another unzip file is open"; return false; } auto unzip = d->archive->d->unzip; if (unzLocateFile(unzip, d->filepath.toUtf8(), 1) != UNZ_OK) { PAINTFIELD_WARNING << "file not found"; return false; } unz_file_info64 fileInfo; unzGetCurrentFileInfo64(unzip, &fileInfo, 0, 0, 0, 0, 0, 0); d->size = fileInfo.uncompressed_size; if (unzOpenCurrentFile(unzip) != UNZ_OK) { PAINTFIELD_WARNING << "failed to open current file"; return false; } setOpenMode(ReadOnly); return true; }
int do_extract_from_opened_pack_archive_onefile( unzFile uf, const char* filename, int opt_extract_without_path, const char* prefix_extracting_name, int transform_path_separator, int quiet) { int iCaseSensitivity = 1; if (unzLocateFile(uf,filename,iCaseSensitivity)!=UNZ_OK) { u_printf("file %s not found in the zipfile\n",filename); return 2; } if (is_last_char_path_separator(prefix_extracting_name)) { if (quiet == 0) u_printf("Creating extracting directory: %s\n",prefix_extracting_name); mkDirPortable(prefix_extracting_name); } if (do_extract_from_opened_pack_archive_currentfile(uf,&opt_extract_without_path,prefix_extracting_name,transform_path_separator,quiet) == UNZ_OK) return 0; else return 1; }
/* * Open a data file. */ data_file_t * data_file_open(char *name) { char *n; FILE *fh; zipped_t *z; if (path.zip) { z = malloc(sizeof(zipped_t)); z->name = strdup(name); z->zip = unzDup(path.zip); if (unzLocateFile(z->zip, name, 0) != UNZ_OK || unzOpenCurrentFile(z->zip) != UNZ_OK) { unzClose(z->zip); z = NULL; } return (data_file_t *)z; } else { n = malloc(strlen(path.name) + strlen(name) + 2); sprintf(n, "%s/%s", path.name, name); str_slash(n); fh = fopen(n, "rb"); return (data_file_t *)fh; } }
bool eFileTypeZIP::Open(const char* name) const { char contain_path[xIo::MAX_PATH_LEN]; char contain_name[xIo::MAX_PATH_LEN]; if(Contain(name, contain_path, contain_name)) { unzFile h = unzOpen64(contain_path); if(!h) return false; bool ok = false; if(unzLocateFile(h, contain_name, 0) == UNZ_OK) { ok = OpenCurrent(h); } unzClose(h); return ok; } char opened_name[xIo::MAX_PATH_LEN]; bool ok = Open(unzOpen64(name), opened_name); if(ok) { char full_name[xIo::MAX_PATH_LEN]; strcpy(full_name, name); strcat(full_name, "/"); strcat(full_name, opened_name); OpLastFile(full_name); } return ok; }
void getFileListFromZip(VectorFileInfo& _result, const char*_zipfile, const std::string& _folder, const std::string& filename) { unzFile pFile = NULL; std::string path = _folder + filename; bool isDir = false; pFile = unzOpen(_zipfile); if (!pFile) return; do { int nRet = unzLocateFile(pFile, path.c_str(), 1); CC_BREAK_IF(UNZ_OK != nRet); char szFilePathA[260]; unz_file_info unzInfo; nRet = unzGetCurrentFileInfo(pFile, &unzInfo, szFilePathA, sizeof(szFilePathA), NULL, 0, NULL, 0); CC_BREAK_IF(UNZ_OK != nRet); if (szFilePathA[unzInfo.size_filename - 1] == '/' || szFilePathA[unzInfo.size_filename - 1] == '\\') isDir = true; else isDir = false; _result.push_back(FileInfo(filename, isDir)); } while (0); unzClose(pFile); }
int OpenFile(ngePackage* pkg, const char* fname,int flag) { ngePackageZip* zip = (ngePackageZip*)pkg; ngeVFZip* f; unzFile file; if (flag != IO_RDONLY) return 0; file = unzOpen(zip->fname); if (file == NULL) return 0; if(unzLocateFile(file, fname, 0) != UNZ_OK) goto fail; if (zip->passwd == NULL) { if (unzOpenCurrentFile(file) != UNZ_OK) goto fail; } else { if (unzOpenCurrentFilePassword(file, zip->passwd) != UNZ_OK) goto fail; } f = (ngeVFZip*)malloc(sizeof(ngeVFZip)); f->file = file; f->op = &zipFileOperation; return ngeVFAdd((ngeVF*)f); fail: unzClose(file); return 0; }
void logSetPosition(unsigned long pos) { blocks q; unsigned long count = 0; BYTE temp; if (pos >= logMinBlockPosition && pos < logMaxBlockPosition) { logPosition = pos; } else if (pos < logMinBlockPosition) { // Delete all blocks and re-read the file back to our current position while (block != NULL) { q = block; block = block->next; mbDestroy(&(q->item)); } logMinBlockPosition = pos; logMaxBlockPosition = pos; logPosition = pos; unzCloseCurrentFile(logFile); unzClose(logFile); logFile = unzOpen(logFileName); unzLocateFile(logFile, "log.dat", 0); unzOpenCurrentFile(logFile); while (count < pos) { unzReadCurrentFile(logFile, &temp, 1); count++; } zipFilePosition = pos; } else { temp = 1; } }
/* * Open a data file. */ file_t sysfile_open(const char *name) { #ifdef ENABLE_ZIP if (rootPath.zip) { unzFile zh = rootPath.zip; if (unzLocateFile(zh, name, 0) != UNZ_OK || unzOpenCurrentFile(zh) != UNZ_OK) { return NULL; } return (file_t)zh; } else /* uncompressed file */ #endif /* ENABLE_ZIP */ { FILE *fh; char *fullPath = sysmem_push(strlen(rootPath.name) + strlen(name) + 2); if (!fullPath) { return NULL; } sprintf(fullPath, "%s/%s", rootPath.name, name); str_toNativeSeparators(fullPath); fh = fopen(fullPath, "rb"); sysmem_pop(fullPath); return (file_t)fh; } }
bool arcDecompressFile (const CString &sArchive, const CString &sFilename, IWriteStream &Output, CString *retsError) // arcDecompressFile // // Unzips to a stream. { unzFile theZipFile = unzOpen(sArchive.GetASCIIZPointer()); if (theZipFile == NULL) { *retsError = strPatternSubst(CONSTLIT("Unable to open file: %s."), sArchive); return false; } if (unzLocateFile(theZipFile, sFilename.GetASCIIZPointer(), 0) != UNZ_OK) { unzClose(theZipFile); *retsError = strPatternSubst(CONSTLIT("Unable to find file in archive: %s."), sFilename); return false; } if (unzOpenCurrentFile(theZipFile) != UNZ_OK) { unzClose(theZipFile); *retsError = strPatternSubst(CONSTLIT("Unable to open file in archive: %s."), sFilename); return false; } while (true) { char szBuffer[BUFFER_SIZE]; int iRead = unzReadCurrentFile(theZipFile, szBuffer, BUFFER_SIZE); if (iRead == 0) break; else if (iRead < 0) { unzCloseCurrentFile(theZipFile); unzClose(theZipFile); *retsError = CONSTLIT("Error reading archive."); return false; } Output.Write(szBuffer, iRead); } // Returns UNZ_CRCERROR if the file failed its CRC check. if (unzCloseCurrentFile(theZipFile) != UNZ_OK) { unzClose(theZipFile); *retsError = strPatternSubst(CONSTLIT("File in archive corrupted: %s."), sArchive); return false; } unzClose(theZipFile); return true; }