Zlib_article_input_stream * _wsreg_zlibais_open(const char *filename) { Zlib_article_input_stream *ais = NULL; int result; String_util *sutil = _wsreg_strutil_initialize(); if (filename != NULL) { ais = zlibais_create(); ais->pdata->filename = sutil->clone(filename); ais->pdata->unzip_file = unzOpen(ais->pdata->filename); if (ais->pdata->unzip_file == NULL) { zlibais_free(ais); return (NULL); } result = unzGetGlobalInfo(ais->pdata->unzip_file, &ais->pdata->global_info); if (result != UNZ_OK) { unzCloseCurrentFile(ais->pdata->unzip_file); zlibais_free(ais); return (NULL); } } return (ais); }
int zipExtract(unzFile uf, int overwrite, const char* password, ZIP_EXTRACT_CB progress_callback) { uLong i; unz_global_info gi; int err; err = unzGetGlobalInfo(uf,&gi); if (err!=UNZ_OK) { printf("error %d with zipfile in unzGetGlobalInfo \n",err); return 0; } for (i = 0; i < gi.number_entry; i++) { if( progress_callback ) { progress_callback(gi.number_entry, i); } if( !zipExtractCurrentfile(uf, overwrite, password) ) { return 0; } if ((i+1) < gi.number_entry) { err = unzGoToNextFile(uf); if (err!=UNZ_OK) { printf("error %d with zipfile in unzGoToNextFile\n",err); return 0; } } } return 1; }
int PackFileOpen (packfile_t *pf, const char *zname) { int x, max; unz_file_info file_info; strcpy (pf->pak_name, zname); pf->uf = unzOpen (pf->pak_name); if (!pf->uf) { return ERROR_PACK_FILE_NOT_EXIST; } unzGetGlobalInfo (pf->uf, &pf->gi); pf->fi = (fileinfo_t *)malloc (sizeof(fileinfo_t)*pf->gi.number_entry); if (!pf->fi) { unzClose (pf->uf); return ERROT_NOT_ENOUGHT_MEMORY; } max = pf->gi.number_entry; for (x=0; x<max; x++) { unzGetCurrentFileInfo (pf->uf,&file_info, pf->fi[x].name,sizeof(pf->fi[x].name),NULL,0,NULL,0); pf->fi[x].attr = file_info.external_fa; pf->fi[x].offset = file_info.offset; pf->fi[x].size = file_info.uncompressed_size; pf->fi[x].c_offset = file_info.c_offset; pf->fi[x].date = file_info.dosDate; _strlwr( pf->fi[x].name ); unzGoToNextFile (pf->uf); } return 1; }
SEXP R_unzGetGlobalInfo(SEXP r_file) { SEXP r_ans = R_NilValue; unz_global_info pglobal_info ; unzFile file ; int ans ; file = DEREF_REF_PTR_CLASS( r_file , unzFile, unzContent) ; ans = unzGetGlobalInfo ( file, & pglobal_info ) ; PROTECT(r_ans = NEW_LIST( 2 )); SET_VECTOR_ELT(r_ans, 0, ScalarInteger( ans ) ); SET_VECTOR_ELT( r_ans, 1 , R_copyStruct_unz_global_info( &pglobal_info ) ); { const char *names[] = { "", "pglobal_info" }; SET_NAMES(r_ans, R_makeNames(names, 2 )); }; UNPROTECT( 1 ); return(r_ans); }
bool UnZip::getList() { unz_global_info gi; int err = unzGetGlobalInfo(d->uf, &gi); if(err != UNZ_OK) return false; QStringList l; for(int n = 0; n < (int)gi.number_entry; ++n) { char filename_inzip[256]; unz_file_info file_info; int err = unzGetCurrentFileInfo(d->uf, &file_info, filename_inzip, sizeof(filename_inzip), NULL, 0, NULL, 0); if(err != UNZ_OK) return false; l += filename_inzip; if((n+1) < (int)gi.number_entry) { err = unzGoToNextFile(d->uf); if(err != UNZ_OK) return false; } } d->listing = l; return true; }
int extractZip(unzFile uf,int opt_extract_without_path,int opt_overwrite,const char* password) { uLong i; unz_global_info gi; int err; err = unzGetGlobalInfo (uf,&gi); if (err!=UNZ_OK) printf("error %d with zipfile in unzGetGlobalInfo \n",err); for (i=0;i<gi.number_entry;i++) { if (do_extract_currentfile(uf,&opt_extract_without_path, &opt_overwrite, password) != UNZ_OK) break; if ((i+1)<gi.number_entry) { err = unzGoToNextFile(uf); if (err!=UNZ_OK) { printf("error %d with zipfile in unzGoToNextFile\n",err); break; } } } return err; }
int rarch_extract_zipfile(const char *zip_path) { unzFile uf = unzOpen(zip_path); unz_global_info gi; int err = unzGetGlobalInfo(uf, &gi); if (err != UNZ_OK) RARCH_ERR("error %d with ZIP file in unzGetGlobalInfo \n",err); for (unsigned i = 0; i < gi.number_entry; i++) { if (rarch_extract_currentfile_in_zip(uf) != UNZ_OK) break; if ((i + 1) < gi.number_entry) { err = unzGoToNextFile(uf); if (err != UNZ_OK) { RARCH_ERR("error %d with ZIP file in unzGoToNextFile\n",err); break; } } } if(g_console.info_msg_enable) rarch_settings_msg(S_MSG_EXTRACTED_ZIPFILE, S_DELAY_180); return 0; }
void Unzip::getGlobalInfo(void) { unz_global_info info; unzGetGlobalInfo(zipfile_handle, &info); numFiles = info.number_entry; }
int unzip_get_number_entries (const char *filename) { FILE *file; unsigned char magic[4] = { 0 }; #undef fopen #undef fread #undef fclose if ((file = fopen (filename, "rb")) == NULL) { errno = ENOENT; return -1; } fread (magic, 1, sizeof (magic), file); fclose (file); #define fopen fopen2 #define fclose fclose2 #define fread fread2 if (magic[0] == 'P' && magic[1] == 'K' && magic[2] == 0x03 && magic[3] == 0x04) { unz_global_info info; file = (FILE *) unzOpen (filename); unzGetGlobalInfo (file, &info); unzClose (file); return info.number_entry; } else return -1; }
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== quakefile_t *FindQuakeFilesInZip( char *zipfile, char *filter ) { unzFile uf; int err; unz_global_info gi; char filename_inzip[MAX_PATH]; unz_file_info file_info; int i; quakefile_t *qfiles, *lastqf, *qf; uf = unzOpen( zipfile ); err = unzGetGlobalInfo( uf, &gi ); if ( err != UNZ_OK ) { return NULL; } unzGoToFirstFile( uf ); qfiles = NULL; lastqf = NULL; for ( i = 0; i < gi.number_entry; i++ ) { err = unzGetCurrentFileInfo( uf, &file_info, filename_inzip, sizeof( filename_inzip ), NULL,0,NULL,0 ); if ( err != UNZ_OK ) { break; } ConvertPath( filename_inzip ); if ( FileFilter( filter, filename_inzip, false ) ) { qf = GetClearedMemory( sizeof( quakefile_t ) ); if ( !qf ) { Error( "out of memory" ); } memset( qf, 0, sizeof( quakefile_t ) ); strcpy( qf->pakfile, zipfile ); strcpy( qf->filename, zipfile ); strcpy( qf->origname, filename_inzip ); qf->zipfile = true; //memcpy( &buildBuffer[i].zipfileinfo, (unz_s*)uf, sizeof(unz_s)); memcpy( &qf->zipinfo, (unz_s*)uf, sizeof( unz_s ) ); qf->offset = 0; qf->length = file_info.uncompressed_size; qf->type = QuakeFileType( filename_inzip ); //add the file ot the list qf->next = NULL; if ( lastqf ) { lastqf->next = qf; } else { qfiles = qf;} lastqf = qf; } //end if unzGoToNextFile( uf ); } //end for unzClose( uf ); return qfiles; } //end of the function FindQuakeFilesInZip
uint32_t EPUB3GetFileCountInArchive(EPUB3Ref epub) { unz_global_info gi; int err = unzGetGlobalInfo(epub->archive, &gi); if (err != UNZ_OK) return err; return (uint32_t)gi.number_entry; }
int Unzip::GetEntryCount() { unz_global_info pglobal_info; m_errcode = unzGetGlobalInfo(m_unzFile, &pglobal_info); if (m_errcode != UNZ_OK) { return -1; } return (int)pglobal_info.number_entry; }
std::vector<std::pair<std::string, File*>> ZipArchive::GetFiles() { std::vector<std::pair<std::string, File*>> result; unz_global_info globalInfo; if (unzGetGlobalInfo(archive, &globalInfo) != UNZ_OK) { return result; } for (uLong i = 0; i < globalInfo.number_entry; ++i) { // Get the filename size. unz_file_info fileInfo; if (unzGetCurrentFileInfo(archive, &fileInfo, NULL, 0, NULL, 0, NULL, 0) != UNZ_OK) { std::cerr << "Failed to read file info. Entry " << i << " in " << archivePath << std::endl; unzGoToNextFile(archive); continue; } // Get the filename now that we have the filename size. std::string filename; filename.resize(fileInfo.size_filename); if (unzGetCurrentFileInfo(archive, &fileInfo, &filename[0], filename.size(), NULL, 0, NULL, 0) != UNZ_OK) { std::cerr << "Failed to read file info. Entry " << i << " in " << archivePath << std::endl; unzGoToNextFile(archive); continue; } // Do not add directories. if (filename[filename.size() - 1] == '/') { unzGoToNextFile(archive); continue; } // Get the position of the file and create a file. unz_file_pos position; if (unzGetFilePos(archive, &position) != UNZ_OK) { std::cerr << "Failed to read file info. Entry " << i << " in " << archivePath << std::endl; continue; } File* file = new ZipArchiveFile(archive, fileInfo, position, &mutex); result.push_back(std::pair<std::string, File*>(filename, file)); // Move to the next file in the archive. unzGoToNextFile(archive); } return result; }
bool nglZipFS::BuildIndex() { int res; unzFile Zip = mpPrivate->mZip; unz_global_info global_info; if (UNZ_OK != unzGetGlobalInfo(Zip, &global_info)) return false; if (UNZ_OK != unzGoToFirstFile(Zip)) return false; do { unz_file_info file_info; unz_file_pos file_pos; char filename[4096]; if (UNZ_OK != unzGetCurrentFileInfo(Zip, &file_info, filename, 4096, NULL, 0, NULL, 0)) return false; if (UNZ_OK != unzGetFilePos(Zip, &file_pos)) return false; uint len = strlen(filename); bool IsDir = (filename[len-1] == '\\') || (filename[len-1] == '/'); std::list<nglPath> List; nglZipPath::Decompose(filename, List); std::list<nglPath>::iterator it; std::list<nglPath>::iterator end = List.end(); Node* pPath = &mRoot; int i = List.size(); for (it = List.begin(); it != end; ++it) { nglString name = (*it).GetPathName(); Node* pChild = pPath->Find(name); if (!pChild) { //printf("zipfile: %s\n", name.GetChars()); pChild = new Node(name, file_info.uncompressed_size, file_pos.pos_in_zip_directory, file_pos.num_of_file, i == 1 && !IsDir); pPath->AddChild(pChild); } pPath = pChild; i--; } } while (UNZ_OK == (res = unzGoToNextFile(Zip))); if (res == UNZ_END_OF_LIST_OF_FILE) return true; return false; }
bool Unzip::Open(const std::string &path) { m_unzFile = unzOpen(path.c_str()); unz_global_info pglobal_info; unzGetGlobalInfo(m_unzFile, &pglobal_info); printf("number_entry %lu\n", pglobal_info.number_entry); printf("number_disk_with_CD %lu\n", pglobal_info.number_disk_with_CD); return (m_unzFile != nullptr); }
void readInZipFileName() { //FileUtils::getInstance()->getWritablePath(); //●●● filePath=/data/data/com.superman.plane/files/ ●●● std::string filePath = "/storage/sdcard0/Android/obb/com.superman.plane/"; std::string zipFile = "main.2.com.superman.plane.obb"; std::string imgFile = "assets/img_bg_1.jpg"; std::string path = filePath + zipFile; // zipファイルをopenし、ファイル数を取得します。 unzFile zipfile = unzOpen(path.c_str()); log( "--- path = %s ---" ,path.c_str()); unz_global_info global_info; if ( unzGetGlobalInfo( zipfile, &global_info ) != UNZ_OK ) { log( "could not read file global infon" ); unzClose( zipfile ); return; } // ファイルの先頭にカーソルを合わせます unzGoToFirstFile(zipfile); uLong i; for ( i = 0; i < global_info.number_entry; ++i ) { // Get info about current file. char filename[ 100 ]; if ( unzGetCurrentFileInfo64(zipfile, NULL, filename, 100, NULL, 0, NULL, 0) != UNZ_OK ) { log( "could not read file" ); unzClose( zipfile ); return; } std::string str(filename); log("file[%lu] name == %s" , i , str.c_str()); // ここでstd::vectorにでも詰めればOK // 次にカーソルを進める unzGoToNextFile(zipfile); } // 終わったらcloseを忘れずに。 unzClose(zipfile); }
int do_extract_from_opened_pack_archive( unzFile uf, int opt_extract_without_path, const char* prefix_extracting_name, int transform_path_separator, int quiet) { uLong i; unz_global_info gi; int err; int retValue = 0; err = unzGetGlobalInfo(uf,&gi); if (err!=UNZ_OK) { u_printf("error %d with zipfile in unzGetGlobalInfo \n",err); return 1; } if (gi.number_entry != 0) { err = unzGoToFirstFile(uf); if (err!=UNZ_OK) { u_printf("error %d with zipfile in unzGetGlobalInfo \n",err); return 1; } } 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); } for (i=0;i<gi.number_entry;i++) { if (do_extract_from_opened_pack_archive_currentfile(uf,&opt_extract_without_path,prefix_extracting_name,transform_path_separator,quiet) != UNZ_OK) break; if ((i+1)<gi.number_entry) { err = unzGoToNextFile(uf); if (err!=UNZ_OK) { u_printf("error %d with zipfile in unzGoToNextFile\n",err); retValue = 1; } } } return retValue; }
// Get the contents of a zip file into an array of ZipEntrys INT32 ZipGetList(struct ZipEntry** pList, INT32* pnListCount) { if (Zip == NULL) return 1; if (pList == NULL) return 1; unz_global_info ZipGlobalInfo; memset(&ZipGlobalInfo, 0, sizeof(ZipGlobalInfo)); unzGetGlobalInfo(Zip, &ZipGlobalInfo); INT32 nListLen = ZipGlobalInfo.number_entry; // Make an array of File Entries struct ZipEntry* List = (struct ZipEntry *)malloc(nListLen * sizeof(struct ZipEntry)); if (List == NULL) { unzClose(Zip); return 1; } memset(List, 0, nListLen * sizeof(struct ZipEntry)); INT32 nRet = unzGoToFirstFile(Zip); if (nRet != UNZ_OK) { unzClose(Zip); return 1; } // Step through all of the files, until we get to the end INT32 nNextRet = 0; for (nCurrFile = 0, nNextRet = UNZ_OK; nCurrFile < nListLen && nNextRet == UNZ_OK; nCurrFile++, nNextRet = unzGoToNextFile(Zip)) { unz_file_info FileInfo; memset(&FileInfo, 0, sizeof(FileInfo)); nRet = unzGetCurrentFileInfo(Zip, &FileInfo, NULL, 0, NULL, 0, NULL, 0); if (nRet != UNZ_OK) continue; // Allocate space for the filename char* szName = (char *)malloc(FileInfo.size_filename + 1); if (szName == NULL) continue; nRet = unzGetCurrentFileInfo(Zip, &FileInfo, szName, FileInfo.size_filename + 1, NULL, 0, NULL, 0); if (nRet != UNZ_OK) continue; List[nCurrFile].szName = szName; List[nCurrFile].nLen = FileInfo.uncompressed_size; List[nCurrFile].nCrc = FileInfo.crc; } // return the file list *pList = List; if (pnListCount != NULL) *pnListCount = nListLen; unzGoToFirstFile(Zip); nCurrFile = 0; return 0; }
void FileSystemZip::CacheIndex() { assert(m_cache.empty() && "Why would you want to call this twice?"); uLong i; unz_global_info gi; int err; err = unzGetGlobalInfo (m_uf,&gi); if (err!=UNZ_OK) { LogError("error %d with zipfile in unzGetGlobalInfo \n",err); return; } unzGoToFirstFile(m_uf); ZipCacheEntry entry; for (i=0;i<gi.number_entry;i++) { char filename_inzip[512]; unz_file_info file_info; err = unzGetCurrentFileInfo(m_uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0); if (err!=UNZ_OK) { LogError("error %d with zipfile in unzGetCurrentFileInfo\n",err); break; } err = unzGetFilePos(m_uf, &entry.m_filepos); if (err!=UNZ_OK) { LogError("error %d with zipfile in unzGetFilePos\n",err); break; } m_cache[filename_inzip] = entry; if ((i+1)<gi.number_entry) { err = unzGoToNextFile(m_uf); if (err!=UNZ_OK) { LogError("error %d with zipfile in unzGoToNextFile\n",err); break; } } } LogMsg("Cache has %d files.", m_cache.size()); }
int QuaZip::getEntriesCount()const { QuaZip *fakeThis=(QuaZip*)this; // non-const fakeThis->zipError=UNZ_OK; if(mode!=mdUnzip) { qWarning("QuaZip::getEntriesCount(): ZIP is not open in mdUnzip mode"); return -1; } unz_global_info globalInfo; if((fakeThis->zipError=unzGetGlobalInfo(unzFile_f, &globalInfo))!=UNZ_OK) return zipError; return (int)globalInfo.number_entry; }
int rarch_extract_zipfile(const char *zip_path, const char *current_dir, char *first_file, size_t first_file_size, unsigned extract_zip_mode) { bool found_first_file = false; (void)found_first_file; unzFile uf = unzOpen(zip_path); unz_global_info gi; int ret = unzGetGlobalInfo(uf, &gi); if(ret != UNZ_OK) RARCH_ERR("Error %d while trying to get ZIP file global info.\n", ret); for (unsigned i = 0; i < gi.number_entry; i++) { static char write_filename[PATH_MAX]; char slash[6]; #ifdef _XBOX snprintf(slash, sizeof(slash), "\\"); #else snprintf(slash, sizeof(slash), "/"); #endif if (rarch_extract_currentfile_in_zip(uf, current_dir, slash, write_filename, sizeof(write_filename), extract_zip_mode) != UNZ_OK) { RARCH_ERR("Failed to extract current file from ZIP archive.\n"); break; } else { #ifdef HAVE_LIBRETRO_MANAGEMENT if(!found_first_file) { found_first_file = rarch_manage_libretro_extension_supported(write_filename); if(found_first_file) snprintf(first_file, first_file_size, write_filename); } #endif } if ((i + 1) < gi.number_entry) { ret = unzGoToNextFile(uf); if (ret != UNZ_OK) { RARCH_ERR("Error %d while trying to go to the next file in the ZIP archive.\n", ret); break; } } } return 0; }
bool ThemeLoader::extractZip( const std::string &zipFile, const std::string &rootDir ) { bool b_isWsz = strstr( zipFile.c_str(), ".wsz" ); // Try to open the ZIP file zlib_filefunc_def descr; fill_fopen_filefunc( &descr ); descr.zopen_file = open_vlc; descr.opaque = getIntf(); unzFile file = unzOpen2( zipFile.c_str(), &descr ); if( file == 0 ) { msg_Dbg( getIntf(), "failed to open %s as a zip file", zipFile.c_str() ); return false; } unz_global_info info; if( unzGetGlobalInfo( file, &info ) != UNZ_OK ) { msg_Dbg( getIntf(), "failed to read zip info from %s", zipFile.c_str() ); unzClose( file ); return false; } // Extract all the files in the archive for( unsigned long i = 0; i < info.number_entry; i++ ) { if( !extractFileInZip( file, rootDir, b_isWsz ) ) { msg_Warn( getIntf(), "error while unzipping %s", zipFile.c_str() ); unzClose( file ); return false; } if( i < info.number_entry - 1 ) { // Go the next file in the archive if( unzGoToNextFile( file ) != UNZ_OK ) { msg_Warn( getIntf(), "error while unzipping %s", zipFile.c_str() ); unzClose( file ); return false; } } } unzClose( file ); return true; }
static void vfsInitPakFile( const char *filename ){ unz_global_info gi; unzFile uf; guint32 i; int err; uf = unzOpen( filename ); if ( uf == NULL ) { g_FuncTable.m_pfnSysFPrintf( SYS_WRN, " failed to init pak file %s\n", filename ); return; } g_FuncTable.m_pfnSysPrintf( " pak file: %s\n", filename ); g_unzFiles = g_slist_append( g_unzFiles, uf ); err = unzGetGlobalInfo( uf,&gi ); if ( err != UNZ_OK ) { return; } unzGoToFirstFile( uf ); for ( i = 0; i < gi.number_entry; i++ ) { char filename_inzip[NAME_MAX]; unz_file_info file_info; VFS_PAKFILE* file; err = unzGetCurrentFileInfo( uf, &file_info, filename_inzip, sizeof( filename_inzip ), NULL, 0, NULL, 0 ); if ( err != UNZ_OK ) { break; } file = (VFS_PAKFILE*)g_malloc( sizeof( VFS_PAKFILE ) ); g_pakFiles = g_slist_append( g_pakFiles, file ); vfsFixDOSName( filename_inzip ); strlwr( filename_inzip ); file->name = g_strdup( filename_inzip ); file->size = file_info.uncompressed_size; file->zipfile = uf; memcpy( &file->zipinfo, uf, sizeof( unz_s ) ); if ( ( i + 1 ) < gi.number_entry ) { err = unzGoToNextFile( uf ); if ( err != UNZ_OK ) { break; } } } }
static int do_extract( unzFile uf, int opt_extract_without_path, int opt_overwrite, const char* password, const OnProgressCallback* progress ) { uLong i; unz_global_info gi; int err; FILE* fout=NULL; err = unzGetGlobalInfo (uf,&gi); for (i=0;i<gi.number_entry;i++) { if (do_extract_currentfile(uf,&opt_extract_without_path, &opt_overwrite, password) != UNZ_OK) break; if ( progress != NULL ) { short cancel = 0; long progressValue = ( 1000000 / gi.number_entry * i ); if(NULL != progress) (*progress)( UTILS_ONPROGRESSEVENT_ID, progressValue, &cancel ); if ( cancel != 0 ) { return err; } } if ((i+1)<gi.number_entry) { err = unzGoToNextFile(uf); if (err!=UNZ_OK) { break; } } } if ( progress != NULL ) { short cancel = 0; long progressValue = 1000000; if(NULL != progress) (*progress)( UTILS_ONPROGRESSEVENT_ID, progressValue, &cancel ); } return 0; }
static void vfsInitPakFile(const char *filename) { unz_global_info gi; unzFile uf; guint32 i; int err; uf = unzOpen(filename); if(uf == NULL) return; g_unzFiles = g_slist_append(g_unzFiles, uf); err = unzGetGlobalInfo(uf, &gi); if(err != UNZ_OK) return; unzGoToFirstFile(uf); Sys_Printf("VFS Init: %s (pk3)\n", filename); for(i = 0; i < gi.number_entry; i++) { char filename_inzip[NAME_MAX]; unz_file_info file_info; VFS_PAKFILE *file; err = unzGetCurrentFileInfo(uf, &file_info, filename_inzip, sizeof(filename_inzip), NULL, 0, NULL, 0); if(err != UNZ_OK) break; file = (VFS_PAKFILE *) safe_malloc(sizeof(VFS_PAKFILE)); g_pakFiles = g_slist_append(g_pakFiles, file); vfsFixDOSName(filename_inzip); g_strdown(filename_inzip); file->name = strdup(filename_inzip); file->size = file_info.uncompressed_size; file->zipfile = uf; memcpy(&file->zipinfo, uf, sizeof(unz_s)); if((i + 1) < gi.number_entry) { err = unzGoToNextFile(uf); if(err != UNZ_OK) break; } } }
QString QuaZip::getComment()const { QuaZip *fakeThis=(QuaZip*)this; // non-const fakeThis->zipError=UNZ_OK; if(mode!=mdUnzip) { qWarning("QuaZip::getComment(): ZIP is not open in mdUnzip mode"); return QString(); } unz_global_info globalInfo; QByteArray comment; if((fakeThis->zipError=unzGetGlobalInfo(unzFile_f, &globalInfo))!=UNZ_OK) return QString(); comment.resize(globalInfo.size_comment); if((fakeThis->zipError=unzGetGlobalComment(unzFile_f, comment.data(), comment.size()))!=UNZ_OK) return QString(); return commentCodec->toUnicode(comment); }
std::vector<std::string> FileSystemZip::GetContents() { uLong i; unz_global_info gi; int err; char filename_inzip[512]; unz_file_info file_info; std::vector<std::string> contents; err = unzGetGlobalInfo(m_unzf,&gi); if (err!=UNZ_OK) { LogError("error %d with zipfile in unzGetGlobalInfo \n",err); return contents; } unzGoToFirstFile(m_unzf); for (i=0;i<gi.number_entry;i++) { err = unzGetCurrentFileInfo(m_unzf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0); if (err!=UNZ_OK) { LogError("error %d with zipfile in unzGetCurrentFileInfo\n",err); break; } contents.push_back(std::string(filename_inzip)); if ((i+1)<gi.number_entry) { err = unzGoToNextFile(m_unzf); if (err!=UNZ_OK) { LogError("error %d with zipfile in unzGoToNextFile\n",err); break; } } } return contents; }
/* Hand fixed code. */ SEXP R_unzGetGlobalInfo(SEXP r_r873, SEXP r_r905) { SEXP r_ans = R_NilValue; unzFile r873 ; unz_global_info r905 ; int ans ; r873 = DEREF_REF_PTR( r_r873 , unzContent ) ; ans = unzGetGlobalInfo ( r873, &r905 ) ; PROTECT(r_ans = NEW_LIST(2)); SET_VECTOR_ELT(r_ans, 0, ScalarInteger( ans ) ); SET_VECTOR_ELT(r_ans, 1, R_copyStruct_unz_global_info(&r905)); /* names */ UNPROTECT(1); return(r_ans); }
void ZipInput::ReadGlobalInfo(void *masterFile) { // Read number of entries and global comment unz_global_info globalInfo; if (unzGetGlobalInfo(static_cast<unzFile>(masterFile), &globalInfo) != UNZ_OK) { LogPedantic("Failed to read zip global info"); ThrowMsg(Exception::ReadGlobalInfoFailed, "Failed to read global info"); } m_numberOfFiles = static_cast<size_t>(globalInfo.number_entry); m_globalCommentSize = static_cast<size_t>(globalInfo.size_comment); LogPedantic("Number of files: " << m_numberOfFiles); LogPedantic("Global comment size: " << m_globalCommentSize); }
static bool is_file_in_archive(unzFile uf, const wchar_t *filename) { uLong i; unz_global_info gi; int err; err = unzGetGlobalInfo (uf,&gi); for (i = 0; i < gi.number_entry; i++) { if (current_file_is_find(uf, filename) == true) return true; if ((i + 1) < gi.number_entry) { err = unzGoToNextFile(uf); if (err != UNZ_OK) break; } } return false; }