void ZipFile::extract(const std::string& path) { TraceL << "Extracting zip to: " << path << endl; if (!opened()) throw std::runtime_error("The archive must be opened for extraction."); if (!goToFirstFile()) throw std::runtime_error("Cannot read the source archive."); while (true) { extractCurrentFile(path, true); if (!goToNextFile()) break; } }
void unzip_mem(char* buf, int len, TCHAR* dest) { zlib_filefunc64_def ffunc; fill_memory_filefunc64(&ffunc); char zipfile[128]; mir_snprintf(zipfile, sizeof(zipfile), "%p+%x", buf, len); unzFile uf = unzOpen2_64(zipfile, &ffunc); if (uf) { do { extractCurrentFile(uf, dest); } while (unzGoToNextFile(uf) == UNZ_OK); unzClose(uf); } }
bool unzip(const TCHAR *ptszZipFile, TCHAR *ptszDestPath, TCHAR *ptszBackPath,bool ch) { bool bResult = true; zlib_filefunc64_def ffunc; fill_fopen64_filefunc(&ffunc); unzFile uf = unzOpen2_64(ptszZipFile, &ffunc); if (uf) { do { if (!extractCurrentFile(uf, ptszDestPath, ptszBackPath,ch)) bResult = false; } while (unzGoToNextFile(uf) == UNZ_OK); unzClose(uf); } return bResult; }
int minizip_unzip(const char * lpszzipfilename, const char * lpszdirname, const char * lpszpassword) { int nret = -1; int nstatus = 0; int nct = 0; unzFile uf = NULL; // Open zip file if (lpszzipfilename != NULL) { uf = unzOpen64(lpszzipfilename); } if (uf == NULL) { return ERROR_ZIP_FILE_NOT_FOUND; } // Extract all nstatus = unzGoToFirstFile(uf); while (nstatus == UNZ_OK) { chdir(lpszdirname); nstatus = extractCurrentFile(uf, lpszpassword); if (nstatus == UNZ_OK) { nct ++; nstatus =unzGoToNextFile(uf); } } if (nct > 0) { nret = 0; } return nret; }