这篇教程C++ zip_stat_init函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中zip_stat_init函数的典型用法代码示例。如果您正苦于以下问题:C++ zip_stat_init函数的具体用法?C++ zip_stat_init怎么用?C++ zip_stat_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了zip_stat_init函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: r_io_zip_slurp_fileint r_io_zip_slurp_file(RIOZipFileObj *zfo) { int res = R_FALSE; struct zip_stat sb; struct zip_file *zFile = NULL; struct zip * zipArch ; if (!zfo) return res; zipArch = r_io_zip_open_archive ( zfo->archivename, zfo->flags, zfo->mode, zfo->rw); //eprintf("Slurping file"); if (zipArch && zfo && zfo->entry != -1) { zFile = zip_fopen_index (zipArch, zfo->entry, 0); if (!zfo->b) zfo->b = r_buf_new (); zip_stat_init (&sb); if (zFile && zfo->b && !zip_stat_index(zipArch, zfo->entry, 0, &sb) ) { ut8 *buf = malloc (sb.size); memset (buf, 0, sb.size); if (buf) { zip_fread (zFile, buf, sb.size); r_buf_set_bytes (zfo->b, buf, sb.size); res = zfo->opened = R_TRUE; free (buf); } } zip_fclose (zFile); } zip_close (zipArch); return res;}
开发者ID:CodingFree,项目名称:radare2,代码行数:33,
示例2: r_io_zip_alloc_zipfileobj/* The file can be a file in the archive or ::[num]. */RIOZipFileObj* r_io_zip_alloc_zipfileobj(const char *archivename, const char *filename, ut32 perm, int mode, int rw) { RIOZipFileObj *zfo = NULL; ut64 i, num_entries; struct zip_stat sb; struct zip *zipArch = r_io_zip_open_archive (archivename, perm, mode, rw); if (!zipArch) { return NULL; } num_entries = zip_get_num_files (zipArch); for (i = 0; i < num_entries; i++) { zip_stat_init (&sb); zip_stat_index (zipArch, i, 0, &sb); if (sb.name != NULL) { if (strcmp (sb.name, filename) == 0) { zfo = r_io_zip_create_new_file ( archivename, filename, &sb, perm, mode, rw); r_io_zip_slurp_file (zfo); break; } } } if (!zfo) { zfo = r_io_zip_create_new_file (archivename, filename, NULL, perm, mode, rw); } zip_close (zipArch); return zfo;}
开发者ID:csarn,项目名称:radare2,代码行数:31,
示例3: ipsw_get_file_sizeint ipsw_get_file_size(const char* ipsw, const char* infile, off_t* size) { ipsw_archive* archive = ipsw_open(ipsw); if (archive == NULL || archive->zip == NULL) { error("ERROR: Invalid archive/n"); return -1; } int zindex = zip_name_locate(archive->zip, infile, 0); if (zindex < 0) { error("ERROR: zip_name_locate: %s/n", infile); return -1; } struct zip_stat zstat; zip_stat_init(&zstat); if (zip_stat_index(archive->zip, zindex, 0, &zstat) != 0) { error("ERROR: zip_stat_index: %s/n", infile); return -1; } *size = zstat.size; ipsw_close(archive); return 0;}
开发者ID:Blackmamba0,项目名称:idevicerestore,代码行数:25,
示例4: r_io_zip_get_filesRList * r_io_zip_get_files(char *archivename, ut32 flags, int mode, int rw) { ut64 num_entries = 0, i = 0; struct zip * zipArch = r_io_zip_open_archive(archivename, flags, mode, rw); struct zip_stat sb; RList *files = NULL; //eprintf("Slurping file"); if (zipArch) { files = r_list_new(); num_entries = zip_get_num_files(zipArch); for (i=0; i < num_entries; i++) { char *name = NULL; zip_stat_init(&sb ); zip_stat_index(zipArch, i, 0, &sb ); //eprintf("Comparing %s == %s = %d/n", sb.name, filename, strcmp(sb.name, filename)); name = strdup(sb.name); if (name) { r_list_append(files, name); } } } if (zipArch) zip_close(zipArch); return files;}
开发者ID:jdukes,项目名称:radare2,代码行数:27,
示例5: readZipFileName/************************************************* Function: readZipFileName Descroption: Input: 1.zip* z 2.filetype Output: Return: Other:*************************************************/int readZipFileName(struct zip* z, char* filetype){ int i; struct zip_stat fstat; if(z != NULL) { zip_stat_init(&fstat); int c = zip_get_num_files(z); if(c > 0) { for (i = 0 ; i < c; i++) { const char* name = zip_get_name(z, i, 0); if(name != NULL) { zip_stat(z, name,0,&fstat); //LOGI("File %i:%s Size: %lld Size2: %lld/n", i,fstat.name,fstat.size ,fstat.comp_size); } } } } else { return -1; } return 0;}
开发者ID:txl0591,项目名称:RFIDJni,代码行数:39,
示例6: r_io_zip_slurp_filestatic int r_io_zip_slurp_file(RIOZipFileObj *zfo) { struct zip_file *zFile = NULL; struct zip *zipArch; struct zip_stat sb; bool res = false; if (!zfo) { return res; } zipArch = r_io_zip_open_archive ( zfo->archivename, zfo->perm, zfo->mode, zfo->rw); if (zipArch && zfo && zfo->entry != -1) { zFile = zip_fopen_index (zipArch, zfo->entry, 0); if (!zfo->b) { zfo->b = r_buf_new (); } zip_stat_init (&sb); if (zFile && zfo->b && !zip_stat_index (zipArch, zfo->entry, 0, &sb)) { ut8 *buf = malloc (sb.size); memset (buf, 0, sb.size); if (buf) { zip_fread (zFile, buf, sb.size); r_buf_set_bytes (zfo->b, buf, sb.size); res = true; zfo->opened = true; free (buf); } } zip_fclose (zFile); } zip_close (zipArch); return res;}
开发者ID:csarn,项目名称:radare2,代码行数:34,
示例7: zip_source_statZIP_EXTERN intzip_source_stat(zip_source_t *src, zip_stat_t *st){ if (src->source_closed) { return -1; } if (st == NULL) { zip_error_set(&src->error, ZIP_ER_INVAL, 0); return -1; } zip_stat_init(st); if (ZIP_SOURCE_IS_LAYERED(src)) { if (zip_source_stat(src->src, st) < 0) { _zip_error_set_from_source(&src->error, src->src); return -1; } } if (_zip_source_call(src, st, sizeof(*st), ZIP_SOURCE_STAT) < 0) { return -1; } return 0;}
开发者ID:jas88,项目名称:jas88tools,代码行数:26,
示例8: zipruby_stat_allocstatic VALUE zipruby_stat_alloc(VALUE klass) { struct zipruby_stat *p = ALLOC(struct zipruby_stat); p->sb = ALLOC(struct zip_stat); zip_stat_init(p->sb); return Data_Wrap_Struct(klass, 0, zipruby_stat_free, p);}
开发者ID:TimLang,项目名称:zipruby-compatibility-with-rubyzip-fork,代码行数:8,
示例9: zip_stat_initsize_t ZIPProvider::ZIPHandle::fileSize(const FileName & file) { struct zip_stat sb; zip_stat_init(&sb); if (zip_stat(handle, file.getPath().c_str(), 0, &sb) == -1) { WARN(zip_strerror(handle)); return 0; } return static_cast<size_t>(sb.size);}
开发者ID:PADrend,项目名称:Util,代码行数:9,
示例10: OpenZipvoid ZipByteReader::Register(size_t seqId, const std::string& path){ auto zipFile = m_zips.pop_or_create([this]() { return OpenZip(); }); zip_stat_t stat; zip_stat_init(&stat); int err = zip_stat(zipFile.get(), path.c_str(), 0, &stat); if (ZIP_ER_OK != err) RuntimeError("Failed to get file info of %s, zip library error: %s", path.c_str(), GetZipError(err).c_str()); m_seqIdToIndex[seqId] = std::make_pair(stat.index, stat.size); m_zips.push(std::move(zipFile));}
开发者ID:6779660,项目名称:CNTK,代码行数:11,
示例11: zipSourceCallbackstatic zip_int64_t zipSourceCallback(void* userdata, void* data, zip_uint64_t len, zip_source_cmd cmd){ ZipSourceCallbackData* cbData = reinterpret_cast<ZipSourceCallbackData*>(userdata); switch (cmd) { case ZIP_SOURCE_OPEN: cbData->offset = 0; cbData->headerIsDone = false; break; case ZIP_SOURCE_READ: { if(cbData->headerIsDone) { size_t remain = cbData->dataSize-cbData->offset; size_t toCopy = std::min((size_t)len, remain); if(toCopy>0) std::memcpy(data, &cbData->data[cbData->offset], toCopy); cbData->offset += toCopy; return toCopy; } else { size_t remain = cbData->header.size()-cbData->offset; size_t toCopy = std::min((size_t)len, remain); if(toCopy>0) std::memcpy(data, &cbData->header[cbData->offset], toCopy); cbData->offset += toCopy; if(cbData->offset==cbData->header.size()) { cbData->headerIsDone = true; cbData->offset = 0; } return toCopy; } } case ZIP_SOURCE_CLOSE: break; case ZIP_SOURCE_STAT: { struct zip_stat* zs = reinterpret_cast<struct zip_stat*>(data); zip_stat_init(zs); zs->encryption_method = ZIP_EM_NONE; zs->size = cbData->dataSize + cbData->header.size(); /* size of file (uncompressed) */ zs->mtime = std::time(nullptr); zs->comp_method = ZIP_CM_STORE; /* compression method used */ zs->valid = ZIP_STAT_SIZE | ZIP_STAT_MTIME | ZIP_STAT_COMP_METHOD | ZIP_STAT_ENCRYPTION_METHOD; return 0; } case ZIP_SOURCE_ERROR: break; default: break; } return 0;}
开发者ID:allebacco,项目名称:cnpy,代码行数:53,
示例12: _zip_openzip_t *_zip_open(zip_source_t *src, unsigned int flags, zip_error_t *error){ zip_t *za; zip_cdir_t *cdir; struct zip_stat st; zip_uint64_t len; zip_stat_init(&st); if (zip_source_stat(src, &st) < 0) { _zip_error_set_from_source(error, src); return NULL; } if ((st.valid & ZIP_STAT_SIZE) == 0) { zip_error_set(error, ZIP_ER_SEEK, EOPNOTSUPP); return NULL; } len = st.size; /* treat empty files as empty archives */ if (len == 0) { if ((za=_zip_allocate_new(src, flags, error)) == NULL) { zip_source_free(src); return NULL; } return za; } if ((za=_zip_allocate_new(src, flags, error)) == NULL) { return NULL; } if ((cdir = _zip_find_central_dir(za, len)) == NULL) { _zip_error_copy(error, &za->error); /* keep src so discard does not get rid of it */ zip_source_keep(src); zip_discard(za); return NULL; } za->entry = cdir->entry; za->nentry = cdir->nentry; za->nentry_alloc = cdir->nentry_alloc; za->comment_orig = cdir->comment; za->ch_flags = za->flags; free(cdir); return za;}
开发者ID:jmanek,项目名称:lib3mf,代码行数:52,
示例13: ipsw_extract_to_memoryint ipsw_extract_to_memory(const char* ipsw, const char* infile, unsigned char** pbuffer, unsigned int* psize) { ipsw_archive* archive = ipsw_open(ipsw); if (archive == NULL || archive->zip == NULL) { error("ERROR: Invalid archive/n"); return -1; } int zindex = zip_name_locate(archive->zip, infile, 0); if (zindex < 0) { error("ERROR: zip_name_locate: %s/n", infile); return -1; } struct zip_stat zstat; zip_stat_init(&zstat); if (zip_stat_index(archive->zip, zindex, 0, &zstat) != 0) { error("ERROR: zip_stat_index: %s/n", infile); return -1; } struct zip_file* zfile = zip_fopen_index(archive->zip, zindex, 0); if (zfile == NULL) { error("ERROR: zip_fopen_index: %s/n", infile); return -1; } int size = zstat.size; unsigned char* buffer = (unsigned char*) malloc(size+1); if (buffer == NULL) { error("ERROR: Out of memory/n"); zip_fclose(zfile); return -1; } if (zip_fread(zfile, buffer, size) != size) { error("ERROR: zip_fread: %s/n", infile); zip_fclose(zfile); free(buffer); return -1; } buffer[size] = '/0'; zip_fclose(zfile); ipsw_close(archive); *pbuffer = buffer; *psize = size; return 0;}
开发者ID:Blackmamba0,项目名称:idevicerestore,代码行数:50,
示例14: _zip_file_exists/* * tests for file existence */static exists_t_zip_file_exists(zip_source_t *src, zip_error_t *error){ struct zip_stat st; zip_stat_init(&st); if (zip_source_stat(src, &st) != 0) { zip_error_t *src_error = zip_source_error(src); if (zip_error_code_zip(src_error) == ZIP_ER_READ && zip_error_code_system(src_error) == ENOENT) { return EXISTS_NOT; } _zip_error_copy(error, src_error); return EXISTS_ERROR; } return (st.valid & ZIP_STAT_SIZE) && st.size == 0 ? EXISTS_EMPTY : EXISTS_NONEMPTY;}
开发者ID:newser,项目名称:TitanSDK,代码行数:20,
示例15: zip_get_contentsstatic int zip_get_contents(struct zip *zf, const char *filename, int locate_flags, char **buffer, uint32_t *len){ struct zip_stat zs; struct zip_file *zfile; int zindex = zip_name_locate(zf, filename, locate_flags); *buffer = NULL; *len = 0; if (zindex < 0) { return -1; } zip_stat_init(&zs); if (zip_stat_index(zf, zindex, 0, &zs) != 0) { fprintf(stderr, "ERROR: zip_stat_index '%s' failed!/n", filename); return -2; } if (zs.size > 10485760) { fprintf(stderr, "ERROR: file '%s' is too large!/n", filename); return -3; } zfile = zip_fopen_index(zf, zindex, 0); if (!zfile) { fprintf(stderr, "ERROR: zip_fopen '%s' failed!/n", filename); return -4; } *buffer = malloc(zs.size); if (zs.size > LLONG_MAX || zip_fread(zfile, *buffer, zs.size) != (zip_int64_t)zs.size) { fprintf(stderr, "ERROR: zip_fread %" PRIu64 " bytes from '%s'/n", (uint64_t)zs.size, filename); free(*buffer); *buffer = NULL; zip_fclose(zfile); return -5; } *len = zs.size; zip_fclose(zfile); return 0;}
开发者ID:NitzanDavari,项目名称:ideviceinstaller,代码行数:43,
示例16: _zip_source_file_or_pstruct zip_source *_zip_source_file_or_p(struct zip *za, const char *fname, FILE *file, zip_uint64_t start, zip_int64_t len, int closep, const struct zip_stat *st){ struct read_file *f; struct zip_source *zs; if (file == NULL && fname == NULL) { _zip_error_set(&za->error, ZIP_ER_INVAL, 0); return NULL; } if ((f=(struct read_file *)malloc(sizeof(struct read_file))) == NULL) { _zip_error_set(&za->error, ZIP_ER_MEMORY, 0); return NULL; } f->fname = NULL; if (fname) { if ((f->fname=strdup(fname)) == NULL) { _zip_error_set(&za->error, ZIP_ER_MEMORY, 0); free(f); return NULL; } } f->f = file; f->off = start; f->len = (len ? len : -1); f->closep = f->fname ? 1 : closep; if (st) memcpy(&f->st, st, sizeof(f->st)); else zip_stat_init(&f->st); if ((zs=zip_source_function(za, read_file, f)) == NULL) { free(f); return NULL; } return zs;}
开发者ID:Crell,项目名称:php-src,代码行数:42,
示例17: _zip_stat_win32static int_zip_stat_win32(HANDLE h, zip_stat_t *st, _zip_source_win32_read_file_t *ctx){ FILETIME mtimeft; time_t mtime; LARGE_INTEGER size; int regularp; if (!GetFileTime(h, NULL, NULL, &mtimeft)) { zip_error_set(&ctx->error, ZIP_ER_READ, _zip_win32_error_to_errno(GetLastError())); return -1; } if (_zip_filetime_to_time_t(mtimeft, &mtime) < 0) { zip_error_set(&ctx->error, ZIP_ER_READ, ERANGE); return -1; } regularp = 0; if (GetFileType(h) == FILE_TYPE_DISK) { regularp = 1; } if (!GetFileSizeEx(h, &size)) { zip_error_set(&ctx->error, ZIP_ER_READ, _zip_win32_error_to_errno(GetLastError())); return -1; } zip_stat_init(st); st->mtime = mtime; st->valid |= ZIP_STAT_MTIME; if (ctx->end != 0) { st->size = ctx->end - ctx->start; st->valid |= ZIP_STAT_SIZE; } else if (regularp) { st->size = (zip_uint64_t)size.QuadPart; st->valid |= ZIP_STAT_SIZE; } return 0;}
开发者ID:jas88,项目名称:jas88tools,代码行数:41,
示例18: OpenZipvoid ZipByteReader::Register(const std::map<std::string, size_t>& sequences){ auto zipFile = m_zips.pop_or_create([this]() { return OpenZip(); }); zip_stat_t stat; zip_stat_init(&stat); size_t numberOfEntries = 0; size_t numEntries = zip_get_num_entries(zipFile.get(), 0); for (size_t i = 0; i < numEntries; ++i) { int err = zip_stat_index(zipFile.get(), i, 0, &stat); if (ZIP_ER_OK != err) RuntimeError("Failed to get file info for index %d, zip library error: %s", (int)i, GetZipError(err).c_str()); auto sequenceId = sequences.find(std::string(stat.name)); if (sequenceId == sequences.end()) { continue; } else { m_seqIdToIndex[sequenceId->second] = std::make_pair(stat.index, stat.size); numberOfEntries++; } } m_zips.push(std::move(zipFile)); if (numberOfEntries != sequences.size()) { // Not all sequences have been found. Let's print them out and throw. for (const auto& s : sequences) { auto index = m_seqIdToIndex.find(s.second); if (index == m_seqIdToIndex.end()) { fprintf(stderr, "Sequence %s is not found in container %s./n", s.first.c_str(), m_zipPath.c_str()); } } RuntimeError("Cannot retrieve image data for some sequences. For more detail, please see the log file."); }}
开发者ID:Soukiy,项目名称:CNTK,代码行数:41,
示例19: readDexFile/************************************************* Function: readDexFile Descroption: Input: 1.zip* z 2.filename 3.char* buf Output: Return: Other:*************************************************/long readDexFile(struct zip* z, char* filename, unsigned char** buf){ int i; long ReadNum = 0; struct zip_stat fstat; if(z != NULL && NULL != buf) { zip_stat_init(&fstat); int c = zip_get_num_files(z); if(c > 0) { for (i = 0 ; i < c; i++) { const char* name = zip_get_name(z, i, 0); if(0 == strcmp(name,filename)) { zip_stat(z, name,0,&fstat); //LOGI("File %i:%s Size1: %lld Size2: %lld/n", i,fstat.name,fstat.size ,fstat.comp_size); struct zip_file* file = zip_fopen(z, filename, 0); if (file) { *buf =(unsigned char *)malloc(fstat.size+1); memset(*buf,0,(fstat.size+1)); ReadNum = zip_fread(file, *buf,fstat.size); zip_fclose(file); } break; } } } } else { return 0; } return ReadNum;}
开发者ID:txl0591,项目名称:RFIDJni,代码行数:51,
示例20: zip_name_locateSDL_RWops *SDL_RWFromZip(struct zip *z,const char *fname) { zip_file_t* zf; struct zip_stat st; Sint64 idx = zip_name_locate(z, fname, 0); if ( idx < 0){ SDL_SetError("Can't find file %s",fname); return NULL; } //printf("Found file %s with idx %ld/n",fname,idx); zf=zip_fopen_index(z,idx,ZIP_FL_UNCHANGED); if(zf == NULL ){ zip_error_t *error = zip_get_error(z); SDL_SetError("PCK_RWFromZip failed for idx=%ld:%s", idx,zip_error_strerror(error)); zip_error_fini(error); return NULL; } zip_stat_init(&st); if (zip_stat_index(z, idx, 0, &st) == 0) { } SDL_RWops *c = SDL_AllocRW(); if (c == NULL) return NULL; c->seek = sdl_zip_seekfunc; c->size = sdl_zip_sizefunc; c->read = sdl_zip_readfunc; c->write = sdl_zip_writefunc; c->close = sdl_zip_closefunc; c->type = SDL_RW_TAG_CURRENT; ZipInfo* zi = SDL_malloc(sizeof(ZipInfo)); zi->size = st.size; zi->zip = z; c->hidden.unknown.data1 = zf; c->hidden.unknown.data2 = zi; return c;}
开发者ID:filonov-a,项目名称:sdl_pack,代码行数:39,
示例21: r_io_zip_get_filesRList * r_io_zip_get_files(char *archivename, ut32 perm, int mode, int rw) { struct zip *zipArch = r_io_zip_open_archive (archivename, perm, mode, rw); ut64 num_entries = 0, i = 0; RList *files = NULL; struct zip_stat sb; char *name; if (zipArch) { files = r_list_newf (free); if (!files) { zip_close (zipArch); return NULL; } num_entries = zip_get_num_files (zipArch); for (i = 0; i < num_entries; i++) { zip_stat_init (&sb); zip_stat_index (zipArch, i, 0, &sb); if ((name = strdup (sb.name))) { r_list_append (files, name); } } } zip_close (zipArch); return files;}
开发者ID:csarn,项目名称:radare2,代码行数:24,
示例22: _zip_source_file_or_pzip_source_t *_zip_source_file_or_p(const char *fname, FILE *file, zip_uint64_t start, zip_int64_t len, const zip_stat_t *st, zip_error_t *error){ struct read_file *ctx; zip_source_t *zs; if (file == NULL && fname == NULL) { zip_error_set(error, ZIP_ER_INVAL, 0); return NULL; } if ((ctx=(struct read_file *)malloc(sizeof(struct read_file))) == NULL) { zip_error_set(error, ZIP_ER_MEMORY, 0); return NULL; } ctx->fname = NULL; if (fname) { if ((ctx->fname=strdup(fname)) == NULL) { zip_error_set(error, ZIP_ER_MEMORY, 0); free(ctx); return NULL; } } ctx->f = file; ctx->start = start; ctx->end = (len < 0 ? 0 : start+(zip_uint64_t)len); if (st) { memcpy(&ctx->st, st, sizeof(ctx->st)); ctx->st.name = NULL; ctx->st.valid &= ~ZIP_STAT_NAME; } else { zip_stat_init(&ctx->st); } ctx->tmpname = NULL; ctx->fout = NULL; zip_error_init(&ctx->error); ctx->supports = ZIP_SOURCE_SUPPORTS_READABLE | zip_source_make_command_bitmap(ZIP_SOURCE_SUPPORTS, ZIP_SOURCE_TELL, -1); if (ctx->fname) { struct stat sb; if (stat(ctx->fname, &sb) < 0 || S_ISREG(sb.st_mode)) { ctx->supports = ZIP_SOURCE_SUPPORTS_WRITABLE; } } else if (fseeko(ctx->f, 0, SEEK_CUR) == 0) { ctx->supports = ZIP_SOURCE_SUPPORTS_SEEKABLE; } if ((zs=zip_source_function_create(read_file, ctx, error)) == NULL) { free(ctx->fname); free(ctx); return NULL; } return zs;}
开发者ID:15774211127,项目名称:AndroLua,代码行数:61,
示例23: zip_get_num_filesAbstractFSProvider::status_t ZIPProvider::ZIPHandle::dir( const std::string & localDirectory, std::list<FileName> & result, const uint8_t flags) { int num = zip_get_num_files(handle); if (num == -1) { WARN(zip_strerror(handle)); return FAILURE; } struct zip_stat sb; zip_stat_init(&sb); // Iterate over indices. for (int i = 0; i < num; ++i) { if (zip_stat_index(handle, i, 0, &sb) == -1) { WARN(zip_strerror(handle)); return FAILURE; } FileName entryFileName(sb.name); // Determine if the entry is a file or a directory. if (entryFileName.getFile().empty()) { if(!(flags & FileUtils::DIR_DIRECTORIES)) { continue; } if (!(flags & FileUtils::DIR_RECURSIVE)) { std::string entryDirectory = entryFileName.getDir(); if(entryDirectory == localDirectory) { continue; } if(entryDirectory.back() == '/') { entryDirectory.resize(entryDirectory.size() - 1); } const auto slashPos = entryDirectory.find_last_of('/'); if(slashPos != std::string::npos) { entryDirectory = entryDirectory.substr(0, slashPos + 1); } else { entryDirectory.clear(); } // Compare the parent directory of the directory with the requested localDirectory. if(entryDirectory != localDirectory) { continue; } } } else { if(!(flags & FileUtils::DIR_FILES)) { continue; } // Compare the directory of the file with the requested localDirectory. if (!(flags & FileUtils::DIR_RECURSIVE) && entryFileName.getDir() != localDirectory) { continue; } } // Check for hidden files beginning with '.' (files only). if (entryFileName.getFile().front() == '.' && !(flags & FileUtils::DIR_HIDDEN_FILES)) { continue; } FileName f; f.setFSName(archiveRoot.getFSName()); f.setDir(archiveRoot.getDir() + entryFileName.getDir()); f.setFile(entryFileName.getFile()); result.push_back(f); } return OK;}
开发者ID:PADrend,项目名称:Util,代码行数:72,
示例24: _zip_source_win32_handle_or_namezip_source_t *_zip_source_win32_handle_or_name(const void *fname, HANDLE h, zip_uint64_t start, zip_int64_t len, int closep, const zip_stat_t *st, _zip_source_win32_file_ops_t *ops, zip_error_t *error){ _zip_source_win32_read_file_t *ctx; zip_source_t *zs; if (h == INVALID_HANDLE_VALUE && fname == NULL) { zip_error_set(error, ZIP_ER_INVAL, 0); return NULL; } if ((ctx = (_zip_source_win32_read_file_t *)malloc(sizeof(_zip_source_win32_read_file_t))) == NULL) { zip_error_set(error, ZIP_ER_MEMORY, 0); return NULL; } ctx->fname = NULL; if (fname) { if ((ctx->fname = ops->op_strdup(fname)) == NULL) { zip_error_set(error, ZIP_ER_MEMORY, 0); free(ctx); return NULL; } } ctx->ops = ops; ctx->h = h; ctx->start = start; ctx->end = (len < 0 ? 0 : start + (zip_uint64_t)len); ctx->closep = ctx->fname ? 1 : closep; if (st) { memcpy(&ctx->st, st, sizeof(ctx->st)); ctx->st.name = NULL; ctx->st.valid &= ~ZIP_STAT_NAME; } else { zip_stat_init(&ctx->st); } ctx->tmpname = NULL; ctx->hout = INVALID_HANDLE_VALUE; zip_error_init(&ctx->error); ctx->supports = ZIP_SOURCE_SUPPORTS_READABLE | zip_source_make_command_bitmap(ZIP_SOURCE_SUPPORTS, ZIP_SOURCE_TELL, -1); if (ctx->fname) { HANDLE th; th = ops->op_open(ctx); if (th == INVALID_HANDLE_VALUE || GetFileType(th) == FILE_TYPE_DISK) { ctx->supports = ZIP_SOURCE_SUPPORTS_WRITABLE; } if (th != INVALID_HANDLE_VALUE) { CloseHandle(th); } } else if (GetFileType(ctx->h) == FILE_TYPE_DISK) { ctx->supports = ZIP_SOURCE_SUPPORTS_SEEKABLE; } if ((zs = zip_source_function_create(_win32_read_file, ctx, error)) == NULL) { free(ctx->fname); free(ctx); return NULL; } return zs;}
开发者ID:jas88,项目名称:jas88tools,代码行数:68,
示例25: read_datastatic zip_int64_tread_data(void *state, void *data, zip_uint64_t len, zip_source_cmd_t cmd){ struct read_data *ctx = (struct read_data *)state; switch (cmd) { case ZIP_SOURCE_BEGIN_WRITE: if ((ctx->out = buffer_new_write(WRITE_FRAGMENT_SIZE)) == NULL) { zip_error_set(&ctx->error, ZIP_ER_MEMORY, 0); return -1; } return 0; case ZIP_SOURCE_CLOSE: return 0; case ZIP_SOURCE_COMMIT_WRITE: buffer_free(ctx->in); ctx->in = ctx->out; ctx->out = NULL; return 0; case ZIP_SOURCE_ERROR: return zip_error_to_data(&ctx->error, data, len); case ZIP_SOURCE_FREE: buffer_free(ctx->in); buffer_free(ctx->out); free(ctx); return 0; case ZIP_SOURCE_OPEN: ctx->in->offset = 0; return 0; case ZIP_SOURCE_READ: if (len > ZIP_INT64_MAX) { zip_error_set(&ctx->error, ZIP_ER_INVAL, 0); return -1; } return buffer_read(ctx->in, data, len); case ZIP_SOURCE_REMOVE: { buffer_t *empty = buffer_new_read(NULL, 0, 0); if (empty == 0) { zip_error_set(&ctx->error, ZIP_ER_MEMORY, 0); return -1; } buffer_free(ctx->in); ctx->in = empty; return 0; } case ZIP_SOURCE_ROLLBACK_WRITE: buffer_free(ctx->out); ctx->out = NULL; return 0; case ZIP_SOURCE_SEEK: return buffer_seek(ctx->in, data, len, &ctx->error); case ZIP_SOURCE_SEEK_WRITE: return buffer_seek(ctx->out, data, len, &ctx->error); case ZIP_SOURCE_STAT: { zip_stat_t *st; if (len < sizeof(*st)) { zip_error_set(&ctx->error, ZIP_ER_INVAL, 0); return -1; } st = (zip_stat_t *)data; zip_stat_init(st); st->mtime = ctx->mtime; st->size = ctx->in->size; st->comp_size = st->size; st->comp_method = ZIP_CM_STORE; st->encryption_method = ZIP_EM_NONE; st->valid = ZIP_STAT_MTIME|ZIP_STAT_SIZE|ZIP_STAT_COMP_SIZE|ZIP_STAT_COMP_METHOD|ZIP_STAT_ENCRYPTION_METHOD; return sizeof(*st); } case ZIP_SOURCE_SUPPORTS: return zip_source_make_command_bitmap(ZIP_SOURCE_OPEN, ZIP_SOURCE_READ, ZIP_SOURCE_CLOSE, ZIP_SOURCE_STAT, ZIP_SOURCE_ERROR, ZIP_SOURCE_FREE, ZIP_SOURCE_SEEK, ZIP_SOURCE_TELL, ZIP_SOURCE_BEGIN_WRITE, ZIP_SOURCE_COMMIT_WRITE, ZIP_SOURCE_REMOVE, ZIP_SOURCE_ROLLBACK_WRITE, ZIP_SOURCE_SEEK_WRITE, ZIP_SOURCE_TELL_WRITE, ZIP_SOURCE_WRITE, -1); case ZIP_SOURCE_TELL: if (ctx->in->offset > ZIP_INT64_MAX) { zip_error_set(&ctx->error, ZIP_ER_TELL, EOVERFLOW); return -1; } return (zip_int64_t)ctx->in->offset; case ZIP_SOURCE_TELL_WRITE://.........这里部分代码省略.........
开发者ID:AxiosCros,项目名称:php-src,代码行数:101,
示例26: read_file//.........这里部分代码省略......... } ctx->current = (zip_uint64_t)new_current; if (need_seek) { if (_zip_fseek_u(ctx->f, ctx->current, SEEK_SET, &ctx->error) < 0) { return -1; } } return 0; } case ZIP_SOURCE_SEEK_WRITE: { zip_source_args_seek_t *args; args = ZIP_SOURCE_GET_ARGS(zip_source_args_seek_t, data, len, &ctx->error); if (args == NULL) { return -1; } if (_zip_fseek(ctx->fout, args->offset, args->whence, &ctx->error) < 0) { return -1; } return 0; } case ZIP_SOURCE_STAT: { if (len < sizeof(ctx->st)) return -1; if (ctx->st.valid != 0) memcpy(data, &ctx->st, sizeof(ctx->st)); else { zip_stat_t *st; struct stat fst; int err; if (ctx->f) err = fstat(fileno(ctx->f), &fst); else err = stat(ctx->fname, &fst); if (err != 0) { zip_error_set(&ctx->error, ZIP_ER_READ, errno); return -1; } st = (zip_stat_t *)data; zip_stat_init(st); st->mtime = fst.st_mtime; st->valid |= ZIP_STAT_MTIME; if (ctx->end != 0) { st->size = ctx->end - ctx->start; st->valid |= ZIP_STAT_SIZE; } else if ((fst.st_mode&S_IFMT) == S_IFREG) { st->size = (zip_uint64_t)fst.st_size; st->valid |= ZIP_STAT_SIZE; } } return sizeof(ctx->st); } case ZIP_SOURCE_SUPPORTS: return ctx->supports; case ZIP_SOURCE_TELL: return (zip_int64_t)ctx->current; case ZIP_SOURCE_TELL_WRITE: { off_t ret = ftello(ctx->fout); if (ret < 0) { zip_error_set(&ctx->error, ZIP_ER_TELL, errno); return -1; } return ret; } case ZIP_SOURCE_WRITE: { size_t ret; clearerr(ctx->fout); ret = fwrite(data, 1, len, ctx->fout); if (ret != len || ferror(ctx->fout)) { zip_error_set(&ctx->error, ZIP_ER_WRITE, errno); return -1; } return (zip_int64_t)ret; } default: zip_error_set(&ctx->error, ZIP_ER_OPNOTSUPP, 0); return -1; }}
开发者ID:15774211127,项目名称:AndroLua,代码行数:101,
示例27: main//.........这里部分代码省略......... { _tmp = epdf->d_name; if (_tmp != "." && _tmp != ".." && _tmp.substr(7) == "zip") { time_files.push_back(_tmp.substr(0, 6)); } } } // Sort time files by time in ascending order to convert current_time index to proper file std::sort(time_files.begin(), time_files.end(), timeSort); // Prepare paths to zipped and unzipped files current_zip_file = main_dir + "/" + time_files[current_time] + ".zip"; time_name_in_zip = time_files[current_time]; } // Single file analysis -> Directly convert input to current time file else { current_zip_file = main_dir + "/" + zeroPad(current_time,6) +".zip"; time_name_in_zip = zeroPad(current_time,6); } //Open the ZIP archive int err = 0; int zidx = 0; int fileSize = 0; zip *z = zip_open(current_zip_file.c_str(), 0, &err); //Search for the file of given name const char *name = time_name_in_zip.c_str(); struct zip_stat st; zip_stat_init(&st); zip_stat(z, name, 0, &st); //Alloc memory for its uncompressed contents char *contents = new char[st.size]; // Unzip the compressed file into memory zip_file *f = zip_fopen(z, time_name_in_zip.c_str(), 0); fileSize = st.size; zip_fread(f, contents, fileSize); zip_fclose(f); //And close the archive zip_close(z); // Create signal, background and info output files bg_out_file.open((out_dir + "/" + fileName(atoi(time_name_in_zip.c_str()), "B-")).c_str(), std::ofstream::out | std::ofstream::trunc); s_out_file.open((out_dir + "/" + fileName(atoi(time_name_in_zip.c_str()), "S-")).c_str(), std::ofstream::out | std::ofstream::trunc); infoOut.open((out_dir + "/" + fileName(atoi(time_name_in_zip.c_str()), "I-")).c_str(), std::ofstream::out | std::ofstream::trunc); if (save_waveforms) { waveformOut.open((out_dir + "/" + fileName(atoi(time_name_in_zip.c_str()), "W-")).c_str(), std::ofstream::out | std::ofstream::trunc); } // Begin data processing if file has been properly opened if(err == 0) { waveformCtr = 0; zidx = 0; // Begin reading byte-stream while (zidx < fileSize) { // Read LabView header and get the total number of samples written for each channel in the next chunk of data for (int i=0;i<4;i++)
开发者ID:Nablaquabla,项目名称:sns-analysis,代码行数:67,
示例28: m_filenameBinaryInput::BinaryInput( const std::string& filename, G3DEndian fileEndian, bool compressed) : m_filename(filename), m_bitPos(0), m_bitString(0), m_beginEndBits(0), m_alreadyRead(0), m_length(0), m_bufferLength(0), m_buffer(NULL), m_pos(0), m_freeBuffer(true) { setEndian(fileEndian); // Update global file tracker _internal::currentFilesUsed.insert(m_filename); #if _HAVE_ZIP /* G3DFIX: Use ZIP-library only if defined */ std::string zipfile; if (FileSystem::inZipfile(m_filename, zipfile)) { // Load from zipfile// zipRead(filename, v, s); std::string internalFile = m_filename.substr(zipfile.length() + 1); struct zip* z = zip_open(zipfile.c_str(), ZIP_CHECKCONS, NULL); { struct zip_stat info; zip_stat_init( &info ); // TODO: Docs unclear if zip_stat_init is required. zip_stat(z, internalFile.c_str(), ZIP_FL_NOCASE, &info); m_bufferLength = m_length = info.size; // sets machines up to use MMX, if they want m_buffer = reinterpret_cast<uint8*>(System::alignedMalloc(m_length, 16)); struct zip_file* zf = zip_fopen( z, internalFile.c_str(), ZIP_FL_NOCASE ); { int64 test = zip_fread( zf, m_buffer, m_length ); debugAssertM(test == m_length, internalFile + " was corrupt because it unzipped to the wrong size."); (void)test; } zip_fclose( zf ); } zip_close( z ); if (compressed) { decompress(); } m_freeBuffer = true; return; }#endif // Figure out how big the file is and verify that it exists. m_length = FileSystem::size(m_filename); // Read the file into memory FILE* file = fopen(m_filename.c_str(), "rb"); if (! file || (m_length == -1)) { throw format("File not found: /"%s/"", m_filename.c_str()); return; } if (! compressed && (m_length > INITIAL_BUFFER_LENGTH)) { // Read only a subset of the file so we don't consume // all available memory. m_bufferLength = INITIAL_BUFFER_LENGTH; } else { // Either the length is fine or the file is compressed // and requires us to read the whole thing for zlib. m_bufferLength = m_length; } debugAssert(m_freeBuffer); m_buffer = (uint8*)System::alignedMalloc(m_bufferLength, 16); if (m_buffer == NULL) { if (compressed) { throw "Not enough memory to load compressed file. (1)"; } // Try to allocate a small array; not much memory is available. // Give up if we can't allocate even 1k. while ((m_buffer == NULL) && (m_bufferLength > 1024)) { m_bufferLength /= 2; m_buffer = (uint8*)System::alignedMalloc(m_bufferLength, 16); } } debugAssert(m_buffer); fread(m_buffer, m_bufferLength, sizeof(int8), file); fclose(file); file = NULL; if (compressed) { if (m_bufferLength != m_length) { throw "Not enough memory to load compressed file. (2)"; }//.........这里部分代码省略.........
开发者ID:Blumfield,项目名称:ptc2,代码行数:101,
注:本文中的zip_stat_init函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ ziplistGet函数代码示例 C++ zip_stat_index函数代码示例 |