这篇教程C++ unzOpenCurrentFile函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中unzOpenCurrentFile函数的典型用法代码示例。如果您正苦于以下问题:C++ unzOpenCurrentFile函数的具体用法?C++ unzOpenCurrentFile怎么用?C++ unzOpenCurrentFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了unzOpenCurrentFile函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: fileHandleZipStreaming fileHandleZipStreaming(const file_entry* entry, const Zips& z): _cpos(0) { int r = 0; r = unzGoToFilePos(entry->zp, const_cast<unz_file_pos*>(&entry->pos)); OX_ASSERT(r == UNZ_OK); r = unzOpenCurrentFile(entry->zp); OX_ASSERT(r == UNZ_OK); void* ptr; r = unzRealTell(entry->zp, &_pos, &_size, &ptr); OX_ASSERT(r == UNZ_OK); zlib_filefunc_def* f = (zlib_filefunc_def*)ptr; const char* ssss = z.getZipFileName((int)(size_t)f->opaque); _h = file::open(ssss, "rb"); file::seek(_h, static_cast<unsigned int>(_pos), SEEK_SET); unzCloseCurrentFile(entry->zp); }
开发者ID:Yahor10,项目名称:oxygine-framework,代码行数:22,
示例2: throwvoid FileUtils::extractFromZip(const char* zipFilePath, const char* src, const char* dest) throw (IOException){ unzFile zipFile = unzOpen(zipFilePath); int result = unzLocateFile(zipFile,src,0); if (result == UNZ_OK) { // found a match which is now the current file unzOpenCurrentFile(zipFile); const int chunkSize = 4096; char buffer[chunkSize]; std::ofstream outputFile(dest,std::ofstream::binary); if (!outputFile.good()) { throw IOException("Unable to write to file " + std::string(dest)); } while (true) { int count = unzReadCurrentFile(zipFile,buffer,chunkSize); if (count <= 0) { if (count < 0) { throw IOException("Error extracting file from archive " + std::string(src)); } break; } outputFile.write(buffer,count); } outputFile.close(); unzCloseCurrentFile(zipFile); } else { throw IOException("Unable to find file " + std::string(src) + " in zip archive " + std::string(zipFilePath)); } unzClose(zipFile);}
开发者ID:GlPortal,项目名称:Update-Installer,代码行数:39,
示例3: voidbool FileUtils::mzReadToMemory(unzFile uf, std::vector<unsigned char> *output, void (*cb)(uint64_t bytes, void *), void *userData){ unz_file_info64 fi; if (!mzGetInfo(uf, &fi, nullptr)) { return false; } std::vector<unsigned char> data; data.reserve(fi.uncompressed_size); int ret = unzOpenCurrentFile(uf); if (ret != UNZ_OK) { return false; } int n; char buf[32768]; while ((n = unzReadCurrentFile(uf, buf, sizeof(buf))) > 0) { if (cb) { cb(data.size() + n, userData); } data.insert(data.end(), buf, buf + n); } unzCloseCurrentFile(uf); if (n != 0) { return false; } data.swap(*output); return true;}
开发者ID:iebie,项目名称:DualBootPatcher,代码行数:38,
示例4: fullPathbool FileUtils::mzExtractFile(unzFile uf, const std::string &directory){ unz_file_info64 fi; std::string filename; if (!mzGetInfo(uf, &fi, &filename)) { return false; } std::string fullPath(directory); fullPath += "/"; fullPath += filename; boost::filesystem::path path(fullPath); boost::filesystem::create_directories(path.parent_path()); std::ofstream file(fullPath, std::ios::binary); if (file.fail()) { return false; } int ret = unzOpenCurrentFile(uf); if (ret != UNZ_OK) { return false; } int n; char buf[32768]; while ((n = unzReadCurrentFile(uf, buf, sizeof(buf))) > 0) { file.write(buf, n); } unzCloseCurrentFile(uf); return n == 0;}
开发者ID:iebie,项目名称:DualBootPatcher,代码行数:38,
示例5: dukzip_unz_readfilestatic duk_ret_t dukzip_unz_readfile(duk_context *ctx) { unz_file_info fileInfo; unzFile archive = dukzip_unz_from_this(ctx); int ret = UNZ_OK; unzGetCurrentFileInfo(archive, &fileInfo, NULL, 0, NULL, 0, NULL, 0); void *bytes = duk_push_fixed_buffer(ctx, fileInfo.uncompressed_size); ret = unzOpenCurrentFile(archive); if (ret != UNZ_OK) { duk_error(ctx, DUK_ERR_INTERNAL_ERROR, "unable to open file in archive"); return -1; } ret = unzReadCurrentFile(archive, bytes, fileInfo.uncompressed_size); if (ret < 0) { duk_error(ctx, DUK_ERR_INTERNAL_ERROR, "unable to read file in archive"); return -1; } unzCloseCurrentFile(archive); return 1;}
开发者ID:armornick,项目名称:duktape-misc,代码行数:23,
示例6: filesizeZipReader::ZipReader(const char *fn) : filesize(0), zipready(false) { unz_file_info cFileInfo; //Create variable to hold info for a compressed file char cFileName[sizeof(cname)]; if(zipfile = unzOpen(fn)) { //Open zip file for(int cFile = unzGoToFirstFile(zipfile); cFile == UNZ_OK; cFile = unzGoToNextFile(zipfile)) { //Gets info on current file, and places it in cFileInfo unzGetCurrentFileInfo(zipfile, &cFileInfo, cFileName, sizeof(cname), 0, 0, 0, 0); //verify uncompressed file is not bigger than max ROM size if((cFileInfo.uncompressed_size <= 0x1000000 + 512) && (cFileInfo.uncompressed_size > filesize)) { strcpy(cname, cFileName); filesize = cFileInfo.uncompressed_size; } } if(filesize) { unzLocateFile(zipfile, cname, 1); unzOpenCurrentFile(zipfile); zipready = true; } }}
开发者ID:GunioRobot,项目名称:quickdev16,代码行数:23,
示例7: managed_unzip_stream_to_streamgbooleanmanaged_unzip_stream_to_stream (ManagedStreamCallbacks *source, ManagedStreamCallbacks *dest, const char *partname){ zlib_filefunc_def funcs; unzFile zipFile; gboolean ret; ret = FALSE; funcs.zopen_file = managed_stream_open; funcs.zread_file = managed_stream_read; funcs.zwrite_file = managed_stream_write; funcs.ztell_file = managed_stream_tell; funcs.zseek_file = managed_stream_seek; funcs.zclose_file = managed_stream_close; funcs.zerror_file = managed_stream_error; funcs.opaque = source; zipFile = unzOpen2 (NULL, &funcs); if (!zipFile) return FALSE; if (unzLocateFile (zipFile, partname, 2) != UNZ_OK) goto cleanup; if (unzOpenCurrentFile (zipFile) != UNZ_OK) goto cleanup; ret = managed_unzip_extract_to_stream (zipFile, dest);cleanup: unzCloseCurrentFile (zipFile); unzClose (zipFile); return ret;}
开发者ID:kangaroo,项目名称:moon,代码行数:37,
示例8: CC_BREAK_IFunsigned char* CCZipFile::getFileDataNoOrder(const char *fileName, unsigned long *pSize){ unsigned char * pBuffer = NULL; if (pSize) { *pSize = 0; } do { CC_BREAK_IF(!m_zipFile); CC_BREAK_IF(m_fileList.empty()); std::map<std::string, struct __ZipEntryInfo>::const_iterator it = m_fileList.find(fileName); CC_BREAK_IF(it == m_fileList.end()); __ZipEntryInfo fileInfo = it->second; int nRet = unzGoToFilePos(m_zipFile, &fileInfo.pos); CC_BREAK_IF(UNZ_OK != nRet); nRet = unzOpenCurrentFile(m_zipFile); CC_BREAK_IF(UNZ_OK != nRet); //MARK unfinish process big file pBuffer = new unsigned char[fileInfo.uncompressed_size]; int CC_UNUSED nSize = unzReadCurrentFile(m_zipFile, pBuffer, fileInfo.uncompressed_size); CCAssert(nSize == 0 || nSize == (int)fileInfo.uncompressed_size, "the file size is wrong"); if (pSize) { *pSize = fileInfo.uncompressed_size; } unzCloseCurrentFile(m_zipFile); } while (0); return pBuffer;}
开发者ID:gooderman,项目名称:vv2d,代码行数:37,
示例9: XSYNCZIP_getEntryDataByNameint XSYNCZIP_getEntryDataByName ( XDRM_CTRL_CONTEXT_PTR pCtx, char *name, char *buffer ){ int retval =0;#if 0 // before info unz_file_info64 cur_file_infoSaved; unz_file_info64_internal cur_file_info_internalSaved; ZPOS64_T num_fileSaved; ZPOS64_T pos_in_central_dirSaved; /* Save the current state */ num_fileSaved = s->num_file; pos_in_central_dirSaved = s->pos_in_central_dir; cur_file_infoSaved = s->cur_file_info; cur_file_info_internalSaved = s->cur_file_info_internal;#endif if ( unzLocateFile ( pCtx->pZipFile,name,0/*CASESENSITIVITY*/ ) !=UNZ_OK ) { retval= -1; } else { retval = unzOpenCurrentFile ( pCtx->pZipFile ); if ( retval == UNZ_OK ) {#if 0 retval =unzReadCurrentFile ( pCtx->pZipFile, buffer, ( unsigned int ) pCtx->pZipFile->cur_file_info.uncompressed_size );#else retval =unzReadEntry ( pCtx->pZipFile, buffer, 0, ( unsigned int ) pCtx->pZipFile->cur_file_info.uncompressed_size, Z_FINISH );#endif } else { retval =-1; } } unzCloseCurrentFile ( pCtx->pZipFile ); return retval;}
开发者ID:SoongChoi,项目名称:anywall,代码行数:37,
示例10: ERR_FAIL_COND_VunzFile ZipArchive::get_file_handle(String p_file) const { ERR_FAIL_COND_V(!file_exists(p_file), NULL); File file = files[p_file]; FileAccess* f = FileAccess::open(packages[file.package].filename, FileAccess::READ); ERR_FAIL_COND_V(!f, NULL); zlib_filefunc_def io; zeromem(&io, sizeof(io)); io.opaque = f; io.zopen_file = godot_open; io.zread_file = godot_read; io.zwrite_file = godot_write; io.ztell_file = godot_tell; io.zseek_file = godot_seek; io.zclose_file = godot_close; io.zerror_file = godot_testerror; io.alloc_mem = godot_alloc; io.free_mem = godot_free; unzFile pkg = unzOpen2(packages[file.package].filename.utf8().get_data(), &io); ERR_FAIL_COND_V(!pkg, NULL); int unz_err = unzGoToFilePos(pkg, &file.file_pos); ERR_FAIL_COND_V(unz_err != UNZ_OK, NULL); if (unzOpenCurrentFile(pkg) != UNZ_OK) { unzClose(pkg); ERR_FAIL_V(NULL); }; return pkg;};
开发者ID:baekdahl,项目名称:godot,代码行数:36,
示例11: OpenCurrentbool eFileTypeZIP::OpenCurrent(unzFile h, char* name) const{ unz_file_info fi; char n[xIo::MAX_PATH_LEN]; if(unzGetCurrentFileInfo(h, &fi, n, xIo::MAX_PATH_LEN, NULL, 0, NULL, 0) != UNZ_OK) return false; const eFileType* t = eFileType::FindByName(n); if(!t) return false; if(unzOpenCurrentFile(h) != UNZ_OK) return false; bool ok = false; byte* buf = new byte[fi.uncompressed_size]; if(unzReadCurrentFile(h, buf, fi.uncompressed_size) == int(fi.uncompressed_size)) { ok = t->Open(buf, fi.uncompressed_size); if(ok && name) strcpy(name, n); } SAFE_DELETE_ARRAY(buf); unzCloseCurrentFile(h); return ok;}
开发者ID:djdron,项目名称:UnrealSpeccyP,代码行数:24,
示例12: blocksCreate// Size in MBbool blocksCreate(char *fileName, int size) { bool returnValue = TRUE; blockKey = 0; logMaxMemory = size * 2; if (logMaxMemory < 2) { logMaxMemory = 2; } block = NULL; logFile = NULL; logMinBlockPosition = 0; logMaxBlockPosition = 0; logPosition = 0; zipFilePosition = 0; logFile = unzOpen(fileName); if (logFile == NULL) { returnValue = FALSE; } if (returnValue == TRUE) { strcpy(logFileName, fileName); if (unzLocateFile(logFile, "log.dat", 0) != UNZ_OK) { returnValue = FALSE; } } if (returnValue == TRUE) { if (unzOpenCurrentFile(logFile) != UNZ_OK) { returnValue = FALSE; } } return returnValue;}
开发者ID:1taplay,项目名称:winbolo,代码行数:37,
示例13: ExtractFilebool CZipArchive::ExtractFile(std::size_t index)//----------------------------------------------{ if(index >= contents.size()) { return false; } data.clear(); unz_file_pos bestFile; unz_file_info info; bestFile.pos_in_zip_directory = static_cast<uLong>(contents[index].cookie1); bestFile.num_of_file = static_cast<uLong>(contents[index].cookie2); if(unzGoToFilePos(zipFile, &bestFile) == UNZ_OK && unzOpenCurrentFile(zipFile) == UNZ_OK) { unzGetCurrentFileInfo(zipFile, &info, nullptr, 0, nullptr, 0, nullptr, 0); try { data.resize(info.uncompressed_size); } catch(...) { unzCloseCurrentFile(zipFile); return false; } unzReadCurrentFile(zipFile, &data[0], info.uncompressed_size); unzCloseCurrentFile(zipFile); return true; } return false;}
开发者ID:luaman,项目名称:modplug,代码行数:36,
示例14: unz_extractstatic void unz_extract(void **ptr, size_t *size, const char *filename){ unz_file_info info; char *data, *data_end; int got; if (!unz_exists(filename)) FATAL("Failed to locate packaged file: %s", filename); if (unzOpenCurrentFile(foundzip) != UNZ_OK) FATAL("Failed to unpack %s", filename); unzGetCurrentFileInfo(foundzip, &info, NULL, 0, NULL, 0, NULL, 0); data = (char*)malloc(info.uncompressed_size+1); *ptr = data; *size = info.uncompressed_size; data_end = data + info.uncompressed_size; *data_end = 0; while ((got = unzReadCurrentFile(foundzip, data, data_end - data)) > 0) { data = data + got; } unzCloseCurrentFile(foundzip);}
开发者ID:Protovision,项目名称:io-lua,代码行数:24,
示例15: apk_uncompress_internalenum ApkResultapk_uncompress_internal(AndroidApk *apk, char **buffer, size_t *size){ zlib_filefunc_def filefunc; fill_memory_filefunc(&filefunc); char *old_buffer = *buffer; char path[1024]; sprintf(path, "%x+%x", *buffer, *size); /* Decompress a single file in a .zip from memory */ unz_file_info info; unzFile *unz = unzOpen2(path, &filefunc); unzGoToFirstFile(unz); unzGetCurrentFileInfo(unz, &info, NULL, 0, NULL, 0, NULL, 0); *size = info.uncompressed_size; *buffer = malloc(*size); unzOpenCurrentFile(unz); unzReadCurrentFile(unz, *buffer, *size); unzCloseCurrentFile(unz); unzClose(unz); free(old_buffer); return APK_OK;}
开发者ID:raimue,项目名称:apkenv,代码行数:24,
示例16: dr_load_sectionSDL_bool dr_load_section(unzFile *gz, SECTION s, Uint8 *current_buf) { LIST *l; for(l=s.item;l;l=l->next) { SECTION_ITEM *item=l->data; if (strcmp(item->filename,"-")!=0) { /* nouveau fichier, on l'ouvre */ if (unzLocateFile(gz, item->filename, 2) == UNZ_END_OF_LIST_OF_FILE) { unzClose(gz); return SDL_FALSE; } if (unzOpenCurrentFile(gz) != UNZ_OK) { unzClose(gz); return SDL_FALSE; } } create_progress_bar(item->filename); if (item->type==LD_ALTERNATE) zfread_alternate(gz, current_buf + item->begin, item->size, 2); else zfread(gz, current_buf + item->begin, item->size); } return SDL_TRUE;}
开发者ID:joshdekock,项目名称:jim-pspware,代码行数:24,
示例17: PackFileGetFileWithIndexint PackFileGetFileWithIndex (packfile_t *pf, int idx , char **buf){ DWORD err; if (idx >= (int)pf->gi.number_entry) return ERROR_FILE_NOT_EXIST; *buf = (char *)malloc (pf->fi[idx].size); unzLocateFileMy (pf->uf, idx, pf->fi[idx].c_offset); unzOpenCurrentFile (pf->uf); err = unzReadCurrentFile (pf->uf,*buf,pf->fi[idx].size); unzCloseCurrentFile (pf->uf); if (err!=pf->fi[idx].size) { free (*buf); *buf = NULL; return ERROR_FILE_NOT_EXTRACTED; } return pf->fi[idx].size;}
开发者ID:gthgame,项目名称:gth,代码行数:24,
示例18: unzGoToFilePos char* Zip::getFileData(const char* filename, unsigned long& size) { char * pBuffer = NULL; auto it = _files.find(filename); if (it == _files.end()) return NULL; ZipEntryInfo fileInfo = it->second; int nRet = unzGoToFilePos(_zipFile, &fileInfo.pos); if (UNZ_OK != nRet) return NULL; nRet = unzOpenCurrentFile(_zipFile); if (UNZ_OK != nRet) return NULL; pBuffer = new char[fileInfo.uncompressed_size]; unzReadCurrentFile(_zipFile, pBuffer, fileInfo.uncompressed_size); size = fileInfo.uncompressed_size; unzCloseCurrentFile(_zipFile); return pBuffer; }
开发者ID:MacroGu,项目名称:NoahGameFrame,代码行数:24,
示例19: zipio_create_io_from_filevoid ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_progress) { FileAccess *fa = NULL; zlib_filefunc_def io = zipio_create_io_from_file(&fa); unzFile pkg = unzOpen2(p_file.utf8().get_data(), &io); if (!pkg) { EditorNode::get_singleton()->show_warning(TTR("Can't open export templates zip.")); return; } int ret = unzGoToFirstFile(pkg); int fc = 0; //count them and find version String version; while (ret == UNZ_OK) { unz_file_info info; char fname[16384]; ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0); String file = fname; if (file.ends_with("version.txt")) { Vector<uint8_t> data; data.resize(info.uncompressed_size); //read unzOpenCurrentFile(pkg); ret = unzReadCurrentFile(pkg, data.ptrw(), data.size()); unzCloseCurrentFile(pkg); String data_str; data_str.parse_utf8((const char *)data.ptr(), data.size()); data_str = data_str.strip_edges(); // Version number should be of the form major.minor[.patch].status[.module_config] // so it can in theory have 3 or more slices. if (data_str.get_slice_count(".") < 3) { EditorNode::get_singleton()->show_warning(vformat(TTR("Invalid version.txt format inside templates: %s."), data_str)); unzClose(pkg); return; } version = data_str; } if (file.get_file().size() != 0) { fc++; } ret = unzGoToNextFile(pkg); } if (version == String()) { EditorNode::get_singleton()->show_warning(TTR("No version.txt found inside templates.")); unzClose(pkg); return; } String template_path = EditorSettings::get_singleton()->get_templates_dir().plus_file(version); DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); Error err = d->make_dir_recursive(template_path); if (err != OK) { EditorNode::get_singleton()->show_warning(TTR("Error creating path for templates:") + "/n" + template_path); unzClose(pkg); return; } memdelete(d); ret = unzGoToFirstFile(pkg); EditorProgress *p = NULL; if (p_use_progress) { p = memnew(EditorProgress("ltask", TTR("Extracting Export Templates"), fc)); } fc = 0; while (ret == UNZ_OK) { //get filename unz_file_info info; char fname[16384]; unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0); String file = String(fname).get_file(); if (file.size() == 0) { ret = unzGoToNextFile(pkg); continue; } Vector<uint8_t> data; data.resize(info.uncompressed_size);//.........这里部分代码省略.........
开发者ID:RandomShaper,项目名称:godot,代码行数:101,
示例20: vfsLoadFile// NOTE: when loading a file, you have to allocate one extra byte and set it to /0int vfsLoadFile (const char *filename, void **bufferptr, int index){ int i, count = 0; char tmp[NAME_MAX], fixed[NAME_MAX]; GSList *lst; // filename is a full path if (index == -1) { long len; FILE *f; f = fopen (filename, "rb"); if (f == NULL) return -1; fseek (f, 0, SEEK_END); len = ftell (f); rewind (f); *bufferptr = safe_malloc (len+1); if (*bufferptr == NULL) return -1; fread (*bufferptr, 1, len, f); fclose (f); // we need to end the buffer with a 0 ((char*) (*bufferptr))[len] = 0; return len; } *bufferptr = NULL; strcpy (fixed, filename); vfsFixDOSName (fixed); g_strdown (fixed); for (i = 0; i < g_numDirs; i++) { strcpy (tmp, g_strDirs[i]); strcat (tmp, filename); if (access (tmp, R_OK) == 0) { if (count == index) { long len; FILE *f; f = fopen (tmp, "rb"); if (f == NULL) return -1; fseek (f, 0, SEEK_END); len = ftell (f); rewind (f); *bufferptr = safe_malloc (len+1); if (*bufferptr == NULL) return -1; fread (*bufferptr, 1, len, f); fclose (f); // we need to end the buffer with a 0 ((char*) (*bufferptr))[len] = 0; return len; } count++; } } for (lst = g_pakFiles; lst != NULL; lst = g_slist_next (lst)) { VFS_PAKFILE* file = (VFS_PAKFILE*)lst->data; if (strcmp (file->name, fixed) != 0) continue; if (count == index) { memcpy (file->zipfile, &file->zipinfo, sizeof (unz_s)); if (unzOpenCurrentFile (file->zipfile) != UNZ_OK) return -1; *bufferptr = safe_malloc (file->size+1); // we need to end the buffer with a 0 ((char*) (*bufferptr))[file->size] = 0; i = unzReadCurrentFile (file->zipfile , *bufferptr, file->size); unzCloseCurrentFile (file->zipfile); if (i < 0) return -1; else return file->size; }//.........这里部分代码省略.........
开发者ID:AEonZR,项目名称:GtkRadiant,代码行数:101,
示例21: _zipLoadFile/********************************************************************************* Description*** Load a file in a zip file into memory.****** Arguments*** zipName - Name of zip file*** fileName - Name of file insize zipfile to load*** size - Output of size of file****** Return*** Pointer to allocate memory buffer with file content or NULL on*** failure.***********************************************************************************/void* _zipLoadFile(const char* zipName, const char* fileName, int* size, zlib_filefunc_def* filefunc){ void* buf; char name[256]; unzFile zip; unz_file_info info; *size = 0; 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 = unzOpen2(zipName, filefunc); if (!zip) { return NULL; }#ifdef __APPLE__ // Most OS X installs are on a case-insensitive FS if (unzLocateFile(zip, name, 2) == UNZ_END_OF_LIST_OF_FILE) {#else if (unzLocateFile(zip, name, 1) == UNZ_END_OF_LIST_OF_FILE) {#endif unzClose(zip); return NULL; } if (unzOpenCurrentFile(zip) != UNZ_OK) { return NULL; } unzGetCurrentFileInfo(zip,&info,NULL,0,NULL,0,NULL,0); buf = malloc(info.uncompressed_size); *size = info.uncompressed_size; if (!buf) { unzCloseCurrentFile(zip); unzClose(zip); return NULL; } unzReadCurrentFile(zip, buf, info.uncompressed_size); unzCloseCurrentFile(zip); unzClose(zip); return buf;}/********************************************************************************* Description*** Read cache to speed-up reading multiple files from one zip.*********************************************************************************/static char *cacheData = NULL, cacheFile[512];static zlib_filefunc_def cacheFilefunc;void* zipLoadFile(const char* zipName, const char* fileName, int* size){ if (strncmp(zipName, "mem", 3) == 0) { return memFileLoad(zipName, fileName, size); } if( cacheData != NULL && *cacheFile != '/0' && 0==strcmp(cacheFile, zipName) ) { return _zipLoadFile(cacheData, fileName, size, &cacheFilefunc); }else{ return _zipLoadFile(zipName, fileName, size, NULL); }}void zipCacheReadOnlyZip(const char* zipName){ if (zipName != NULL && strncmp(zipName, "mem", 3) == 0) { return; } *cacheFile = '/0';//.........这里部分代码省略.........
开发者ID:CocoaMSX,项目名称:CocoaMSX,代码行数:101,
示例22: fill_fopen64_filefunc//.........这里部分代码省略......... us.isZip64 = 0; if (ZSEEK64(us.z_filefunc, us.filestream, central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0) err=UNZ_ERRNO; if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) err=UNZ_ERRNO; if (unz64local_getShort(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK) err=UNZ_ERRNO; if (unz64local_getShort(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK) err=UNZ_ERRNO; if (unz64local_getShort(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) err=UNZ_ERRNO; us.gi.number_entry = uL; if (unz64local_getShort(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) err=UNZ_ERRNO; number_entry_CD = uL; if ((number_entry_CD!=us.gi.number_entry) || (number_disk_with_CD!=0) || (number_disk!=0)) err=UNZ_BADZIPFILE; if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) err=UNZ_ERRNO; us.size_central_dir = uL; if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) err=UNZ_ERRNO; us.offset_central_dir = uL; if (unz64local_getShort(&us.z_filefunc, us.filestream,&us.gi.size_comment)!=UNZ_OK) err=UNZ_ERRNO; } if ((central_pos<us.offset_central_dir+us.size_central_dir) && (err==UNZ_OK)) err=UNZ_BADZIPFILE; if (err!=UNZ_OK) { ZCLOSE64(us.z_filefunc, us.filestream); return NULL; } us.byte_before_the_zipfile = central_pos - (us.offset_central_dir+us.size_central_dir); us.central_pos = central_pos; us.pfile_in_zip_read = NULL; us.encrypted = 0; s=(unz64_s*)ALLOC(sizeof(unz64_s)); if( s != NULL) { *s=us; Bytef buf[UNZ_BUFSIZE]; char name[100]; if (unzGoToFirstFile((unzFile)s) != UNZ_OK) return (unzFile)UNZ_ERRNO; ::CreateDirectory(m_uncompresspath.GetBuffer(MAX_PATH), NULL); m_uncompresspath.ReleaseBuffer(); do { unzOpenCurrentFile((unzFile)s); uInt filelength = unzReadCurrentFile((unzFile)s, buf, UNZ_BUFSIZE); unz64local_GetCurrentFileInfoInternal((unzFile)s, &s->cur_file_info, &s->cur_file_info_internal, name,100,NULL,0,NULL,0); std::wstring path = m_uncompresspath.GetString(); path += L"//"; std::wstring filename = Strings::StringToWString(name); path += filename; HANDLE hfile = CreateFile(path.c_str(), GENERIC_WRITE, 0, 0, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0); CloseHandle(hfile); FILE* file; _wfopen_s(&file, path.c_str(), L"wb"); fwrite(buf, 1, filelength, file); fclose(file); } while(unzGoToNextFile((unzFile)s) == UNZ_OK); unzClose((unzFile)s); } return (unzFile)s;}
开发者ID:XyzalZhang,项目名称:SPlayer,代码行数:101,
示例23: sizeofbool ThemeLoader::extractFileInZip( unzFile file, const string &rootDir, bool isWsz ){ // Read info for the current file char filenameInZip[256]; unz_file_info fileInfo; if( unzGetCurrentFileInfo( file, &fileInfo, filenameInZip, sizeof( filenameInZip), NULL, 0, NULL, 0 ) != UNZ_OK ) { return false; } // Convert the file name to lower case, because some winamp skins // use the wrong case... if( isWsz ) for( size_t i = 0; i < strlen( filenameInZip ); i++ ) filenameInZip[i] = tolower( filenameInZip[i] ); // Allocate the buffer void *pBuffer = malloc( ZIP_BUFFER_SIZE ); if( !pBuffer ) return false; // Get the path of the file OSFactory *pOsFactory = OSFactory::instance( getIntf() ); string fullPath = rootDir + pOsFactory->getDirSeparator() + fixDirSeparators( filenameInZip ); string basePath = getFilePath( fullPath ); // Extract the file if is not a directory if( basePath != fullPath ) { if( unzOpenCurrentFile( file ) ) { free( pBuffer ); return false; } makedir( basePath.c_str() ); FILE *fout = fopen( fullPath.c_str(), "wb" ); if( fout == NULL ) { msg_Err( getIntf(), "error opening %s", fullPath.c_str() ); free( pBuffer ); return false; } // Extract the current file int n; do { n = unzReadCurrentFile( file, pBuffer, ZIP_BUFFER_SIZE ); if( n < 0 ) { msg_Err( getIntf(), "error while reading zip file" ); free( pBuffer ); return false; } else if( n > 0 ) { if( fwrite( pBuffer, n , 1, fout) != 1 ) { msg_Err( getIntf(), "error while writing %s", fullPath.c_str() ); free( pBuffer ); return false; } } } while( n > 0 ); fclose(fout); if( unzCloseCurrentFile( file ) != UNZ_OK ) { free( pBuffer ); return false; } } free( pBuffer ); return true;}
开发者ID:paa,项目名称:vlc,代码行数:83,
示例24: ep//.........这里部分代码省略......... if (err != OK) { EditorNode::add_io_error("Can't ensure that dir is empty:/n"+bar_dir); ERR_FAIL_COND_V(err!=OK,err); }; f = da->get_next(); }; da->list_dir_end(); } else { print_line("ARE YOU CRAZY??? THIS IS A SERIOUS BUG HERE!!!"); ERR_FAIL_V(ERR_OMFG_THIS_IS_VERY_VERY_BAD); } ERR_FAIL_COND_V(!pkg, ERR_CANT_OPEN); int ret = unzGoToFirstFile(pkg); while(ret==UNZ_OK) { //get filename unz_file_info info; char fname[16384]; ret = unzGetCurrentFileInfo(pkg,&info,fname,16384,NULL,0,NULL,0); String file=fname; Vector<uint8_t> data; data.resize(info.uncompressed_size); //read unzOpenCurrentFile(pkg); unzReadCurrentFile(pkg,data.ptr(),data.size()); unzCloseCurrentFile(pkg); //write if (file=="bar-descriptor.xml") { _fix_descriptor(data); } if (file=="icon.png") { bool found=false; if (this->icon!="" && this->icon.ends_with(".png")) { FileAccess *f = FileAccess::open(this->icon,FileAccess::READ); if (f) { data.resize(f->get_len()); f->get_buffer(data.ptr(),data.size()); memdelete(f); found=true; } } if (!found) { String appicon = GlobalConfig::get_singleton()->get("application/icon"); if (appicon!="" && appicon.ends_with(".png")) { FileAccess*f = FileAccess::open(appicon,FileAccess::READ); if (f) {
开发者ID:lonesurvivor,项目名称:godot,代码行数:67,
示例25: mRomCSystem::CSystem(char* gamefile,char* romfile) :mCart(NULL), mRom(NULL), mMemMap(NULL), mRam(NULL), mCpu(NULL), mMikie(NULL), mSusie(NULL){#ifdef _LYNXDBG mpDebugCallback=NULL; mDebugCallbackObject=0;#endif // Select the default filetype UBYTE *filememory=NULL; UBYTE *howardmemory=NULL; ULONG filesize=0; ULONG howardsize=0; mFileType=HANDY_FILETYPE_LNX; if(strcmp(gamefile,"")==0) { // No file filesize=0; filememory=NULL; } else if(IsZip(gamefile)) { // Try and find a file in the zip unzFile *fp; unz_file_info info; char filename_buf[0x100], *ptr; bool gotIt; if((fp=(unzFile*)unzOpen(gamefile))!=NULL) { if(unzGoToFirstFile(fp)!=UNZ_OK) { unzClose(fp); CLynxException lynxerr; lynxerr.Message() << "Handy Error: ZIP File select problems" ; lynxerr.Description() << "The file you selected could not be read." << endl << "(The ZIP file may be corrupted)." << endl ; throw(lynxerr); } gotIt = FALSE; for (;;) { // Get file descriptor and analyse if(unzGetCurrentFileInfo(fp, &info, filename_buf, 0x100, NULL, 0, NULL, 0) != UNZ_OK) { break; } else { ptr = strchr(filename_buf, '.'); if (ptr != NULL) { char buf[4]; ptr++; buf[0] = tolower(*ptr); ptr++; buf[1] = tolower(*ptr); ptr++; buf[2] = tolower(*ptr); buf[3] = 0; if (!strcmp(buf, "lnx") || !strcmp(buf, "com") || !strcmp(buf, "o")) { // Found a likely file so signal gotIt = TRUE; break; } } // No match so lets try the next file if(unzGoToNextFile(fp)!=UNZ_OK) break; } } // Did we strike gold ? if(gotIt) { if(unzOpenCurrentFile(fp)==UNZ_OK) { // Allocate memory for the rom filesize=info.uncompressed_size; filememory=(UBYTE*) new UBYTE[filesize]; // Read it into memory if(unzReadCurrentFile(fp,filememory,filesize)!=(int)info.uncompressed_size) { unzCloseCurrentFile(fp); unzClose(fp); delete filememory; // Throw a wobbly CLynxException lynxerr; lynxerr.Message() << "Handy Error: ZIP File load problems" ; lynxerr.Description()//.........这里部分代码省略.........
开发者ID:alexthissen,项目名称:handy-fork,代码行数:101,
示例26: unzClosebool CSystem::ContextLoad(char *context){ LSS_FILE *fp; bool status=1; UBYTE *filememory=NULL; ULONG filesize=0; // First check for ZIP file if(IsZip(context)) { // Find the file and read into memory // Try and find a file in the zip unzFile *fp; unz_file_info info; char filename_buf[0x100], *ptr; bool gotIt; if((fp=(unzFile*)unzOpen(context))!=NULL) { if(unzGoToFirstFile(fp)!=UNZ_OK) { unzClose(fp); gError->Warning("ContextLoad(): ZIP File select problems, could not read zip file"); return 1; } gotIt = FALSE; for (;;) { // Get file descriptor and analyse if(unzGetCurrentFileInfo(fp, &info, filename_buf, 0x100, NULL, 0, NULL, 0) != UNZ_OK) { break; } else { ptr = strchr(filename_buf, '.'); if (ptr != NULL) { char buf[4]; ptr++; buf[0] = tolower(*ptr); ptr++; buf[1] = tolower(*ptr); ptr++; buf[2] = tolower(*ptr); buf[3] = 0; if (!strcmp(buf, "lss")) { // Found a likely file so signal gotIt = TRUE; break; } } // No match so lets try the next file if(unzGoToNextFile(fp)!=UNZ_OK) break; } } // Did we strike gold ? if(gotIt) { if(unzOpenCurrentFile(fp)==UNZ_OK) { // Allocate memory for the rom filesize=info.uncompressed_size; filememory=(UBYTE*) new UBYTE[filesize]; // Read it into memory if(unzReadCurrentFile(fp,filememory,filesize)!=(int)info.uncompressed_size) { unzCloseCurrentFile(fp); unzClose(fp); delete filememory; // Throw a wobbly gError->Warning("ContextLoad(): ZIP File load problems, could not read data from the zip file"); return 1; } // Got it! unzCloseCurrentFile(fp); unzClose(fp); } } else { gError->Warning("ContextLoad(): ZIP File load problems, could not find an LSS file in the zip archive"); return 1; } } else { gError->Warning("ContextLoad(): ZIP File load problems, could not open the zip archive"); return 1; } } else { FILE *fp;//.........这里部分代码省略.........
开发者ID:alexthissen,项目名称:handy-fork,代码行数:101,
示例27: rarch_extract_currentfile_in_zipstatic int rarch_extract_currentfile_in_zip(unzFile uf){ char filename_inzip[PATH_MAX]; FILE *fout = NULL; unz_file_info file_info; int err = unzGetCurrentFileInfo(uf, &file_info, filename_inzip, sizeof(filename_inzip), NULL, 0, NULL, 0); if (err != UNZ_OK) { RARCH_ERR("Error %d with ZIP file in unzGetCurrentFileInfo./n", err); return err; } size_t size_buf = WRITEBUFFERSIZE; void *buf = malloc(size_buf); if (!buf) { RARCH_ERR("Error allocating memory/n"); return UNZ_INTERNALERROR; } char write_filename[PATH_MAX];#if defined(__CELLOS_LV2__) snprintf(write_filename, sizeof(write_filename), "/dev_hdd1/%s", filename_inzip);#elif defined(_XBOX) snprintf(write_filename, sizeof(write_filename), "cache://%s", filename_inzip);#endif err = unzOpenCurrentFile(uf); if (err != UNZ_OK) RARCH_ERR("Error %d with ZIP file in unzOpenCurrentFile./n", err); else { /* success */ fout = fopen(write_filename, "wb"); if (!fout) RARCH_ERR("Error opening %s./n", write_filename); } if (fout) { RARCH_LOG("Extracting: %s/n", write_filename); do { err = unzReadCurrentFile(uf, buf, size_buf); if (err < 0) { RARCH_ERR("error %d with ZIP file in unzReadCurrentFile./n", err); break; } if (err > 0) { if (fwrite(buf, err, 1, fout) != 1) { RARCH_ERR("Error in writing extracted file./n"); err = UNZ_ERRNO; break; } } } while (err > 0); if (fout) fclose(fout); } if (err == UNZ_OK) { err = unzCloseCurrentFile (uf); if (err != UNZ_OK) RARCH_ERR("Error %d with ZIP file in unzCloseCurrentFile./n", err); } else unzCloseCurrentFile(uf); free(buf); return err;}
开发者ID:damariei,项目名称:RetroArch-Rpi,代码行数:84,
示例28: unzOpenint F3DFile::ReadMD3(const char *pFilename){ pModel = this; char *pBuffer = NULL; // open .pk3 file unzFile zipFile = unzOpen(pFilename); // iterate files in zip int zipFileIndex = unzGoToFirstFile(zipFile); while(zipFileIndex != UNZ_END_OF_LIST_OF_FILE) { MFDebug_Assert(zipFileIndex == UNZ_OK, "Error in .zip file."); char fileNameBuf[256]; unz_file_info fileInfo; unzGetCurrentFileInfo(zipFile, &fileInfo, fileNameBuf, sizeof(fileNameBuf), NULL, 0, NULL, 0); MFString fileName = fileNameBuf; if(fileName.EndsWith(".md3")) { // read fle from zip pBuffer = (char*)malloc(fileInfo.uncompressed_size); unzOpenCurrentFile(zipFile); uint32 bytesRead = unzReadCurrentFile(zipFile, pBuffer, fileInfo.uncompressed_size); unzCloseCurrentFile(zipFile); MFDebug_Assert(bytesRead == fileInfo.uncompressed_size, "Incorrect number of bytes read.."); // get subobject and model name.. int slash = MFMax(fileName.FindCharReverse('/'), fileName.FindCharReverse('//')); MFString subobjectName = fileName.SubStr(slash + 1); MFString modelName = fileName.SubStr(0, slash); slash = MFMax(modelName.FindCharReverse('/'), modelName.FindCharReverse('//')); pModel->name = modelName.SubStr(slash + 1); // search for skin file MFString skinFilename = fileName; skinFilename.TruncateExtension(); skinFilename += "_"; skinFilename += pModel->name; skinFilename += ".skin"; // attempt to read skin.. char *pSkinFile = NULL; zipFileIndex = unzLocateFile(zipFile, skinFilename.CStr(), 0); if(zipFileIndex != UNZ_END_OF_LIST_OF_FILE) { // read skin file from zip unz_file_info skinInfo; char skinName[256]; unzGetCurrentFileInfo(zipFile, &skinInfo, skinName, 256, NULL, 0, NULL, 0); pSkinFile = (char*)MFHeap_TAlloc(skinInfo.uncompressed_size + 1); pSkinFile[skinInfo.uncompressed_size] = 0; unzOpenCurrentFile(zipFile); uint32 skinBytesRead = unzReadCurrentFile(zipFile, pSkinFile, skinInfo.uncompressed_size); unzCloseCurrentFile(zipFile); MFDebug_Assert(skinBytesRead == skinInfo.uncompressed_size, "Incorrect number of bytes read.."); } zipFileIndex = unzLocateFile(zipFile, fileName.CStr(), 0); // parse MD3 ParseMD3File(pBuffer, fileInfo.uncompressed_size, subobjectName.CStr(), pSkinFile); // free file MFHeap_Free(pBuffer); pBuffer = NULL; }/* else if(!MFString_CaseCmp(".skin", &fileName[Max(filenameLen - 5, 0)])) { int a, b; char skinName[256]; // get subobject and model name for(a = filenameLen - 5; a >= 0; a--) { if(fileName[a] == '/' || fileName[a] == '//') break; } char *pSkinName = &fileName[a+1]; for(b = a-1; b >= 0; b--) { if(fileName[b] == '/' || fileName[b] == '//') break; }//.........这里部分代码省略.........
开发者ID:FujiGameJam,项目名称:fuji,代码行数:101,
注:本文中的unzOpenCurrentFile函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ unzlocal_GetCurrentFileInfoInternal函数代码示例 C++ unzOpen2函数代码示例 |