当前位置: 首页>>代码示例>>C++>>正文


C++ zip_stat_init函数代码示例

本文整理汇总了C++中zip_stat_init函数的典型用法代码示例。如果您正苦于以下问题:C++ zip_stat_init函数的具体用法?C++ zip_stat_init怎么用?C++ zip_stat_init使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了zip_stat_init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: r_io_zip_slurp_file

int 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,代码来源:io_zip.c

示例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,代码来源:io_zip.c

示例3: ipsw_get_file_size

int 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,代码来源:ipsw.c

示例4: r_io_zip_get_files

RList * 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,代码来源:io_zip.c

示例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,代码来源:zip_util.c

示例6: r_io_zip_slurp_file

static 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,代码来源:io_zip.c

示例7: zip_source_stat

ZIP_EXTERN int
zip_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,代码来源:zip_source_stat.c

示例8: zipruby_stat_alloc

static 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,代码来源:zipruby_stat.c

示例9: zip_stat_init

size_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,代码来源:ZIPProvider.cpp

示例10: OpenZip

void 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,代码来源:ZipByteReader.cpp

示例11: zipSourceCallback

static 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,代码来源:cnpy.cpp

示例12: _zip_open

zip_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,代码来源:zip_open.c

示例13: ipsw_extract_to_memory

int 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,代码来源:ipsw.c

示例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,代码来源:zip_open.c

示例15: zip_get_contents

static 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,代码来源:ideviceinstaller.c


注:本文中的zip_stat_init函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。