std::vector<std::string> ZipArchive::listFiles(boost::filesystem::path filename) { std::vector<std::string> ret; unzFile file = unzOpen2_64(filename.c_str(), FileStream::GetMinizipFilefunc()); if (unzGoToFirstFile(file) == UNZ_OK) { do { unz_file_info64 info; std::vector<char> filename; unzGetCurrentFileInfo64 (file, &info, nullptr, 0, nullptr, 0, nullptr, 0); filename.resize(info.size_filename); // Get name of current file. Contrary to docs "info" parameter can't be null unzGetCurrentFileInfo64 (file, &info, filename.data(), filename.size(), nullptr, 0, nullptr, 0); ret.push_back(std::string(filename.data(), filename.size())); } while (unzGoToNextFile(file) == UNZ_OK); } unzClose(file); return ret; }
bool zip::ZipArchiveInput::Open( String_t const& archiveName, bool caseSensitive ) { m_archiveName = archiveName; m_caseSensitive = caseSensitive; #ifdef USEWIN32IOAPI zlib_filefunc64_def ffunc; #endif #ifdef USEWIN32IOAPI # ifdef SCARAB_WCHAR_MODE fill_win32_filefunc64W(&ffunc); # else fill_win32_filefunc64A(&ffunc); # endif uf = unzOpen2_64(m_archiveName.c_str(),&ffunc); #else uf = unzOpen64(m_archiveName.c_str()); #endif // USEWIN32IOAPI if (uf==NULL) { m_errorMessage << _T("Can't open ") << m_archiveName << std::endl; return false; } return Index(); }
std::unordered_map<ResourceID, unz64_file_pos> CZipLoader::listFiles(const std::string & mountPoint, const boost::filesystem::path & archive) { std::unordered_map<ResourceID, unz64_file_pos> ret; unzFile file = unzOpen2_64(archive.c_str(), &zlibApi); if(file == nullptr) logGlobal->errorStream() << archive << " failed to open"; if (unzGoToFirstFile(file) == UNZ_OK) { do { unz_file_info64 info; std::vector<char> filename; // Fill unz_file_info structure with current file info unzGetCurrentFileInfo64 (file, &info, nullptr, 0, nullptr, 0, nullptr, 0); filename.resize(info.size_filename); // Get name of current file. Contrary to docs "info" parameter can't be null unzGetCurrentFileInfo64 (file, &info, filename.data(), filename.size(), nullptr, 0, nullptr, 0); std::string filenameString(filename.data(), filename.size()); unzGetFilePos64(file, &ret[ResourceID(mountPoint + filenameString)]); } while (unzGoToNextFile(file) == UNZ_OK); } unzClose(file); return ret; }
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; }
unzFile FileUtils::mzOpenInputFile(const std::string &path) { #if defined(MINIZIP_WIN32) zlib_filefunc64_def zFunc; memset(&zFunc, 0, sizeof(zFunc)); fill_win32_filefunc64W(&zFunc); return unzOpen2_64(utf8::utf8ToUtf16(path).c_str(), &zFunc); #elif defined(MINIZIP_ANDROID) zlib_filefunc64_def zFunc; memset(&zFunc, 0, sizeof(zFunc)); fill_android_filefunc64(&zFunc); return unzOpen2_64(path.c_str(), &zFunc); #else return unzOpen64(path.c_str()); #endif }
int TRI_UnzipFile(char const* filename, char const* outPath, bool skipPaths, bool overwrite, char const* password, std::string& errorMessage) { #ifdef USEWIN32IOAPI zlib_filefunc64_def ffunc; #endif size_t bufferSize = 16384; void* buffer = (void*)TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, bufferSize, false); if (buffer == nullptr) { return TRI_ERROR_OUT_OF_MEMORY; } #ifdef USEWIN32IOAPI fill_win32_filefunc64A(&ffunc); unzFile uf = unzOpen2_64(filename, &ffunc); #else unzFile uf = unzOpen64(filename); #endif if (uf == nullptr) { errorMessage = std::string("unable to open zip file ") + filename; return TRI_ERROR_INTERNAL; } int res = UnzipFile(uf, buffer, bufferSize, outPath, skipPaths, overwrite, password, errorMessage); unzClose(uf); TRI_Free(TRI_UNKNOWN_MEM_ZONE, buffer); return res; }
UnzCtx * MinizipUtils::open_input_file(std::string path) { UnzCtx *ctx = new(std::nothrow) UnzCtx(); if (!ctx) { return nullptr; } #if defined(MINIZIP_WIN32) auto converted = utf8_to_wcs(path); if (!converted) { delete ctx; return nullptr; } ctx->path = std::move(converted.value()); fill_win32_filefunc64W(&ctx->buf.filefunc64); #elif defined(MINIZIP_ANDROID) fill_android_filefunc64(&ctx->buf.filefunc64); ctx->path = std::move(path); #else fill_fopen64_filefunc(&ctx->buf.filefunc64); ctx->path = std::move(path); #endif fill_buffer_filefunc64(&ctx->z_func, &ctx->buf); ctx->uf = unzOpen2_64(ctx->path.c_str(), &ctx->z_func); if (!ctx->uf) { delete ctx; return nullptr; } return ctx; }
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 ); }
BOOL CUnzipper::OpenZip(LPCTSTR szFileName) { CloseZip(); if (szFileName) { zlib_filefunc64_def filefunc_def; fill_fopen64_filefunc(&filefunc_def); filefunc_def.zopen64_file = (open64_file_func)wfopen_file_func; filefunc_def.ztell64_file = (tell64_file_func)ftell64_file_func; filefunc_def.zseek64_file = (seek64_file_func)fseek64_file_func; m_uzFile = unzOpen2_64((const char *)szFileName, &filefunc_def); if (m_uzFile) { // set the default output folder wchar_t* szPath = _wcsdup(szFileName); // strip off extension wchar_t* p = wcsrchr(szPath, '.'); if (p) *p = 0; wcscpy_s(m_szOutputFolder, MAX_PATH + 1, szPath); free(szPath); } } return (m_uzFile != NULL); }
FileUtils::MzUnzCtx * FileUtils::mzOpenInputFile(std::string path) { MzUnzCtx *ctx = new(std::nothrow) MzUnzCtx(); if (!ctx) { return nullptr; } #if defined(MINIZIP_WIN32) fill_win32_filefunc64W(&ctx->buf.filefunc64); ctx->path = utf8::utf8ToUtf16(path); #elif defined(MINIZIP_ANDROID) fill_android_filefunc64(&ctx->buf.filefunc64); ctx->path = std::move(path); #else fill_fopen64_filefunc(&ctx->buf.filefunc64); ctx->path = std::move(path); #endif fill_buffer_filefunc64(&ctx->zFunc, &ctx->buf); ctx->uf = unzOpen2_64(ctx->path.c_str(), &ctx->zFunc); if (!ctx->uf) { free(ctx); return nullptr; } return ctx; }
int XSYNCZIP_Open(IN XDRM_KEYOBJ_PTR pKeyObj, IN const char* pszFilePath, IN time_t tmDateTime, OUT XDRM_CTRL_CONTEXT_PTR* phContext) { int xr; if(NULL==*phContext) { xr= XSYNC_Open( pKeyObj, pszFilePath,tmDateTime, phContext); CHECKXR(xr); } //register function pointers registerIOFuncPtrsForZlib(*phContext); (*phContext)->pZipFile =(unz64_s*) unzOpen2_64(pszFilePath, &((*phContext)->zipFile.z_filefunc.zfile_func64)); if(NULL == (*phContext)->pZipFile) { xr=XDRM_E_FAIL; goto ErrorExit; } EXIT: return xr; ErrorExit: free(*phContext); *phContext = NULL; goto EXIT; }
celix_status_t extractBundle(char * bundleName, char * revisionRoot) { celix_status_t status = CELIX_SUCCESS; char filename_try[MAXFILENAME+16] = ""; unzFile uf=NULL; if (bundleName!=NULL) { # ifdef USEWIN32IOAPI zlib_filefunc64_def ffunc; # endif strncpy(filename_try, bundleName,MAXFILENAME-1); /* strncpy doesnt append the trailing NULL, of the string is too long. */ filename_try[ MAXFILENAME ] = '\0'; # ifdef USEWIN32IOAPI fill_win32_filefunc64A(&ffunc); uf = unzOpen2_64(bundleName,&ffunc); # else uf = unzOpen64(bundleName); # endif if (uf==NULL) { strcat(filename_try,".zip"); # ifdef USEWIN32IOAPI uf = unzOpen2_64(filename_try,&ffunc); # else uf = unzOpen64(filename_try); # endif } } if (uf==NULL) { printf("Cannot open %s or %s.zip\n",bundleName,bundleName); status = CELIX_FILE_IO_EXCEPTION; } else { if (do_extract(uf, revisionRoot) != 0) { status = CELIX_FILE_IO_EXCEPTION; } unzClose(uf); } return status; }
bool UnzipArchive::open() { if (isOpen()) return true; d->unzip = unzOpen2_64(nullptr, &d->fileFuncs); return d->unzip; }
ZipFile::ZipFile(const WCHAR *path, ZipMethod method, Allocator *allocator) : filenames(0, allocator), fileinfo(0, allocator), filepos(0, allocator), allocator(allocator), commentLen(0) { zlib_filefunc64_def ffunc; fill_win32_filefunc64(&ffunc); uf = unzOpen2_64(path, &ffunc); if (uf) ExtractFilenames(method); }
CZipStream::CZipStream(std::shared_ptr<CIOApi> api, const boost::filesystem::path & archive, unz64_file_pos filepos) { zlib_filefunc64_def zlibApi; zlibApi = api->getApiStructure(); file = unzOpen2_64(archive.c_str(), &zlibApi); unzGoToFilePos64(file, &filepos); unzOpenCurrentFile(file); }
ZipFile::ZipFile(IStream *stream, ZipMethod method, Allocator *allocator) : filenames(0, allocator), fileinfo(0, allocator), filepos(0, allocator), allocator(allocator), commentLen(0) { zlib_filefunc64_def ffunc; fill_win32s_filefunc64(&ffunc); uf = unzOpen2_64(stream, &ffunc); if (uf) ExtractFilenames(method); }
unzFile FileUtils::mzOpenInputFile(const std::string &path) { #ifdef USEWIN32IOAPI zlib_filefunc64_def zFunc; memset(&zFunc, 0, sizeof(zFunc)); fill_win32_filefunc64A(&zFunc); return unzOpen2_64(path.c_str(), &zFunc); #else return unzOpen64(path.c_str()); #endif }
bool eFileTypeZIP::Open(const void* data, size_t data_size) const { xIo::eStreamMemory mf(data, data_size); zlib_filefunc64_def zfuncs; zfuncs.zopen64_file = ZOpen; zfuncs.zread_file = ZRead; zfuncs.ztell64_file = ZTell; zfuncs.zseek64_file = ZSeek; zfuncs.zclose_file = ZClose; return Open(unzOpen2_64(&mf, &zfuncs)); }
void ZipFile::init() { zlib_filefunc64_def file_functions; unz_file_info64 info; unz64_file_pos position; boost::scoped_array<char> file_name; String index; Uint32 size; Sint32 ok; file_functions.zopen64_file = open_ifstream_func; file_functions.zread_file = read_istream_func; file_functions.zwrite_file = write_istream_func; file_functions.ztell64_file = tell_istream_func; file_functions.zseek64_file = seek_istream_func; file_functions.zclose_file = close_istream_func; file_functions.zerror_file = error_istream_func; m_file = unzOpen2_64(utf8_to_string(get_name()).c_str(), &file_functions); ok = unzGoToFirstFile(m_file); while (ok == UNZ_OK) { unzGetFilePos64(m_file, &position); unzGetCurrentFileInfo64(m_file, &info, 0, 0, 0, 0, 0, 0); size = info.size_filename; file_name.reset(new char[size + 1]); unzGetCurrentFileInfo64(m_file, 0, file_name.get(), size, 0, 0, 0, 0); index = String(string_to_utf8(std::string( file_name.get(), size))); m_files[index] = ZipFileEntry(position); ok = unzGoToNextFile(m_file); } }
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 ArchiveReader::Enumerate_ZIP() { clPtr<iIStream> TheSource = FSourceFile; FSourceFile->Seek( 0 ); zlib_filefunc64_def ffunc; fill_functions( TheSource.GetInternalPtr(), &ffunc ); unzFile uf = unzOpen2_64( "", &ffunc ); unz_global_info64 gi; int err = unzGetGlobalInfo64( uf, &gi ); 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 ); // WARNING: "error %d with zipfile in unzGoToNextFile\n", err if ( err != UNZ_OK ) { break; } } sFileInfo Info; Info.FOffset = 0; Info.FCompressedSize = file_info.compressed_size; Info.FSize = file_info.uncompressed_size; FFileInfos.push_back( Info ); std::string TheName = Arch_FixFileName( filename_inzip ); FFileInfoIdx[TheName] = ( int )FFileNames.size(); FFileNames.push_back( TheName ); FRealFileNames.push_back( std::string( filename_inzip ) ); } unzClose( uf ); return true; }
static DKObject<UnZipFile> Create(const DKString& zipFile, const DKString& file, const char* password) { if (zipFile.Length() == 0 || file.Length() == 0) return NULL; DKString filename = zipFile.FilePathString(); unzFile uf = NULL; #ifdef _WIN32 { zlib_filefunc64_def ffunc; fill_win32_filefunc64W(&ffunc); uf = unzOpen2_64((const wchar_t*)filename, &ffunc); // UTF16LE } #else { DKStringU8 filenameUTF8(filename); if (filenameUTF8.Bytes() > 0) uf = unzOpen64((const char*)filenameUTF8); // UTF8 } #endif if (uf) { unz_file_info64 file_info; DKStringU8 fileUTF8(file); if (fileUTF8.Bytes() > 0 && unzLocateFile(uf, (const char*)fileUTF8, 0) == UNZ_OK && unzGetCurrentFileInfo64(uf, &file_info, NULL, 0, NULL, 0, NULL, 0) == UNZ_OK && file_info.uncompressed_size > 0) { if (unzOpenCurrentFilePassword(uf, password) == UNZ_OK) { DKObject<UnZipFile> p = DKOBJECT_NEW UnZipFile(uf, file_info, password); return p; } else { DKLog("[%s] failed to open file: %ls.\n", DKLIB_FUNCTION_NAME, (const wchar_t*)file); } } } return NULL; }
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; }
extern "C" HZIP OpenArchiveW(WCHAR *lpstrZipFile,char *lpPassword,int dwPasswordLen,bool bZipInMem,int dwFileSize) { void *r=NULL; if (lpstrZipFile) { ZIPDECOMPRESSION *p=(ZIPDECOMPRESSION*)_alloc(sizeof(ZIPDECOMPRESSION)); p->bHandleType=HT_DECOMPRESSOR; if (p) { zlib_filefunc64_def ffunc; p->bInMem=bZipInMem; if (!bZipInMem) fill_fopen64_filefunc(&ffunc); else { fill_memory_filefunc(&ffunc); char filePath[30]; wsprintfA(filePath,"%x+%x",(int)lpstrZipFile,dwFileSize); lpstrZipFile=(WCHAR*)filePath; } if (((lpPassword) && (dwPasswordLen > 0))) { p->bEncrypted=true; memcpy(p->szPassword,lpPassword,dwPasswordLen); } p->hZip=unzOpen2_64(lpstrZipFile,&ffunc); if (p->hZip) r=p; } if (!r) MemFree(p); } else ArchSetLastError(ARCH_INVALID_PARAMETER); return r; }
// //////////////////////////////////////////////////////////////////////////////// // @public @static 将指定 zip 解压至指定路径下 // bool ZipTools::UnZip(LPCWSTR wzZipName, LPCWSTR wzDestPath) { // // 检查指定文件和文件夹是否存在 // if ( !FileTools::Exist(wzZipName) ) { DebugTools::OutputDebugPrintfW(L"[ZipTools] [UnZip] File Not Exist. [%s]\r\n", wzZipName); return false; } if ( !FileTools::Exist(wzDestPath) ) { DebugTools::OutputDebugPrintfW(L"[ZipTools] [Zip] Path Not Exist. [%s]\r\n", wzDestPath); return false; } // 打开 zip 文件 zlib_filefunc64_def ffunc; fill_win32_filefunc64W(&ffunc); unzFile uf = unzOpen2_64(wzZipName, &ffunc); if ( NULL == uf ) { DebugTools::OutputDebugPrintfW( L"[ZipTools] [Zip] Open Zip File Failed.[%s]\r\n", wzZipName); } // 设置指定目录为工作目录 SetCurrentDirectoryW(wzDestPath); // 释放文件 ExtractFile(uf); unzClose(uf); return true; }
int TRI_UnzipFile (const char* filename, const char* outPath, const bool skipPaths, const bool overwrite, const char* password) { unzFile uf; #ifdef USEWIN32IOAPI zlib_filefunc64_def ffunc; #endif void* buffer; size_t bufferSize; int res; bufferSize = 16384; buffer = (void*) TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, bufferSize, false); if (buffer == NULL) { return TRI_ERROR_OUT_OF_MEMORY; } #ifdef USEWIN32IOAPI fill_win32_filefunc64A(&ffunc); uf = unzOpen2_64(filename, &ffunc); #else uf = unzOpen64(filename); #endif res = UnzipFile(uf, buffer, bufferSize, outPath, skipPaths, overwrite, password); unzClose(uf); TRI_Free(TRI_UNKNOWN_MEM_ZONE, buffer); return res; }
HRESULT WINAPI CZipFsEnum::Enum(__in IFsEnumContext *context) { HRESULT hr; zlib_filefunc64_def ffunc; BSTR lpFileName = NULL; IVirtualFs * container = NULL; if (context == NULL) return E_INVALIDARG; hr = context->GetSearchContainer(&container); if (FAILED(hr)) return hr; FillFunctions64((voidpf)container, &ffunc); hr = container->GetFullPath(&lpFileName); if (FAILED(hr)) { container->Release(); return hr; } unzFile uf = NULL; uf = unzOpen2_64(lpFileName, &ffunc); SysFreeString(lpFileName); if (uf == NULL) { container->Release(); return E_FAIL; } hr = ReadArchiver(container, context, uf); unzClose(uf); container->Release(); return hr; }
int main(int argc,char *argv[]) { char zipfilename[MAXFILENAME]= {0}; char filename_to_extract[MAXFILENAME]= {0}; const char *password=NULL; char filename_try[MAXFILENAME+16] = ""; int i; int ret_value=0; int opt_do_list=0; int opt_do_extract=1; int opt_do_extract_withoutpath=0; int opt_overwrite=0; int opt_extractdir=0; char dirname[MAXFILENAME]= {0}; unzFile uf=NULL; do_banner(); if (argc==1) { do_help(); return 0; } else { for (i=1; i<argc; i++) { if ((*argv[i])=='-') { const char *p=argv[i]+1; while ((*p)!='\0') { char c=*(p++);; if ((c=='l') || (c=='L')) opt_do_list = 1; if ((c=='v') || (c=='V')) opt_do_list = 1; if ((c=='x') || (c=='X')) opt_do_extract = 1; if ((c=='e') || (c=='E')) opt_do_extract = opt_do_extract_withoutpath = 1; if ((c=='o') || (c=='O')) opt_overwrite=1; if ((c=='d') || (c=='D')) { opt_extractdir=1; strcat(dirname,__DIR__); strcat(dirname,"/"); strcat(dirname,argv[i+1]); } if (((c=='p') || (c=='P')) && (i+1<argc)) { password=argv[i+1]; i++; } } } else { if (!strlen(zipfilename)) { strcat(zipfilename,__DIR__); strcat(zipfilename,"/"); strcat(zipfilename,argv[i]); } else if ((!strlen(filename_to_extract)) && (!opt_extractdir)) { strcat(filename_to_extract,__DIR__); strcat(filename_to_extract,"/"); strcat(filename_to_extract,argv[i]); } } } } if (strlen(zipfilename)) { # ifdef USEWIN32IOAPI zlib_filefunc64_def ffunc; # endif strncpy(filename_try, zipfilename,MAXFILENAME-1); /* strncpy doesnt append the trailing NULL, of the string is too long. */ filename_try[ MAXFILENAME ] = 0; # ifdef USEWIN32IOAPI fill_win32_filefunc64A(&ffunc); uf = unzOpen2_64(zipfilename,&ffunc); # else uf = unzOpen64(zipfilename); # endif if (uf==NULL) { strcat(filename_try,".zip"); # ifdef USEWIN32IOAPI uf = unzOpen2_64(filename_try,&ffunc); # else uf = unzOpen64(filename_try); # endif } } if (uf==NULL) { printf("Cannot open %s or %s.zip\n",zipfilename,zipfilename); return 1; } printf("%s opened\n",filename_try); if (opt_do_list==1) ret_value = do_list(uf); else if (opt_do_extract==1) { chdir(__DIR__); #ifdef _WIN32 if (opt_extractdir && _chdir(dirname)) #else if (opt_extractdir && chdir(dirname)) #endif { printf("Error changing into %s, aborting\n", dirname); exit(-1); } if (!strlen(filename_to_extract)) ret_value = do_extract(uf, opt_do_extract_withoutpath, opt_overwrite, password); else ret_value = do_extract_onefile(uf, filename_to_extract, opt_do_extract_withoutpath, opt_overwrite, password); } unzClose(uf); return ret_value; }
unsigned char * LoadFirstFileInZip(const char* path,unsigned int *length) { unzFile uf=NULL; void* buf=NULL; # ifdef USEWIN32IOAPI zlib_filefunc64_def ffunc; # endif # ifdef USEWIN32IOAPI fill_win32_filefunc64A(&ffunc); uf = unzOpen2_64(path,&ffunc); # else uf = unzOpen64(path); # endif if (uf==NULL) { printf("Cannot open %s as zip\n",path); return 0; } // Was do Extract- - { uLong i; unz_global_info64 gi; int err; err = unzGetGlobalInfo64(uf,&gi); if (err!=UNZ_OK || gi.number_entry<1) { printf("error %d with zipfile in unzGetGlobalInfo \n",err); return 0; } { char filename_inzip[256]; char* filename_withoutpath; char* p; int err=UNZ_OK; FILE *fout=NULL; uInt size_buf; unz_file_info64 file_info; uLong ratio=0; err = unzGetCurrentFileInfo64(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0); if (err!=UNZ_OK) { printf("error %d with zipfile in unzGetCurrentFileInfo\n",err); return 0; } size_buf=file_info.uncompressed_size; buf = malloc(file_info.uncompressed_size); if (buf==NULL) { printf("Error allocating memory\n"); return 0; } err = unzOpenCurrentFilePassword(uf,NULL); if (err!=UNZ_OK) { printf("error %d with zipfile in unzOpenCurrentFilePassword\n",err); return 0; } do { err = unzReadCurrentFile(uf,buf,size_buf); if (err<0) { printf("error %d with zipfile in unzReadCurrentFile\n",err); return 0; } } while (err>0); if (err==UNZ_OK) { err = unzCloseCurrentFile (uf); if (err!=UNZ_OK) { printf("error %d with zipfile in unzCloseCurrentFile\n",err); return 0; } } *length=size_buf; } } unzClose(uf); return buf; }