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


C++ zip_source_free函数代码示例

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


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

示例1: zip_fopen_index_encrypted

ZIP_EXTERN struct zip_file *
zip_fopen_index_encrypted(struct zip *za, zip_uint64_t index, zip_flags_t flags,
			  const char *password)
{
    struct zip_file *zf;
    struct zip_source *src;

    if ((src=_zip_source_zip_new(za, za, index, flags, 0, 0, password)) == NULL)
	return NULL;

    if (zip_source_open(src) < 0) {
	_zip_error_set_from_source(&za->error, src);
	zip_source_free(src);
	return NULL;
    }

    if ((zf=_zip_file_new(za)) == NULL) {
	zip_source_free(src);
	return NULL;
    }

    zf->src = src;

    return zf;
}
开发者ID:13572293130,项目名称:radare2,代码行数:25,代码来源:zip_fopen_index_encrypted.c

示例2: r_io_zip_flush_file

int r_io_zip_flush_file(RIOZipFileObj *zfo) {
	int res = false;
	struct zip * zipArch;

	if (!zfo) {
		return res;
	}

	zipArch = r_io_zip_open_archive (
		zfo->archivename, zfo->perm, zfo->mode, zfo->rw);
	if (!zipArch) {
		return res;
	}

	struct zip_source *s = zip_source_buffer (zipArch, zfo->b->buf, zfo->b->length, 0);
	if (s && zfo->entry != -1) {
		if (zip_replace(zipArch, zfo->entry, s) == 0) {
			res = true;
		}
	} else if (s && zfo->name) {
		if (zip_add (zipArch, zfo->name, s) == 0) {
			zfo->entry = zip_name_locate (zipArch, zfo->name, 0);
			res = true;
		}
	}
	// s (zip_source) is freed when the archive is closed, i think - dso
	zip_close (zipArch);
	if (s) {
		zip_source_free (s);
	}
	return res;
}
开发者ID:csarn,项目名称:radare2,代码行数:32,代码来源:io_zip.c

示例3: zip_discard

void
zip_discard(zip_t *za)
{
    zip_uint64_t i;

    if (za == NULL)
	return;

    if (za->src) {
	zip_source_close(za->src);
	zip_source_free(za->src);
    }

    free(za->default_password);
    _zip_string_free(za->comment_orig);
    _zip_string_free(za->comment_changes);

    if (za->entry) {
	for (i=0; i<za->nentry; i++)
	    _zip_entry_finalize(za->entry+i);
	free(za->entry);
    }

    for (i=0; i<za->nopen_source; i++) {
	_zip_source_invalidate(za->open_source[i]);
    }
    free(za->open_source);

    zip_error_fini(&za->error);
    
    free(za);

    return;
}
开发者ID:3MFConsortium,项目名称:lib3mf,代码行数:34,代码来源:zip_discard.c

示例4: vfs_zipfile_get_tls

VFSZipFileTLS* vfs_zipfile_get_tls(VFSNode *node, bool create) {
	VFSZipFileData *zdata = node->data1;
	VFSZipFileTLS *tls = SDL_TLSGet(zdata->tls_id);

	if(tls || !create) {
		return tls;
	}

	tls = calloc(1, sizeof(VFSZipFileTLS));
	SDL_TLSSet(zdata->tls_id, tls, (void(*)(void*))vfs_zipfile_free_tls);

	zip_source_t *src = zip_source_function_create(vfs_zipfile_srcfunc, node, &tls->error);
	zip_t *zip = tls->zip = zip_open_from_source(src, ZIP_RDONLY, &tls->error);

	// FIXME: Taisei currently doesn't handle zip files without explicit directory entries correctly (file listing will not work)

	if(!zip) {
		char *r = vfs_node_repr(zdata->source, true);
		vfs_set_error("Failed to open zip archive '%s': %s", r, zip_error_strerror(&tls->error));
		free(r);
		vfs_zipfile_free_tls(tls);
		SDL_TLSSet(zdata->tls_id, 0, NULL);
		zip_source_free(src);
		return NULL;
	}

	return tls;
}
开发者ID:laochailan,项目名称:taisei,代码行数:28,代码来源:zipfile.c

示例5: add_from_zip

static int
add_from_zip(int argc, char *argv[]) {
    zip_uint64_t idx, start;
    zip_int64_t len;
    int err;
    zip_source_t *zs;
    /* add from another zip file */
    idx = strtoull(argv[2], NULL, 10);
    start = strtoull(argv[3], NULL, 10);
    len = strtoll(argv[4], NULL, 10);
    if ((z_in[z_in_count]=zip_open(argv[1], ZIP_CHECKCONS, &err)) == NULL) {
	zip_error_t error;
	zip_error_init_with_code(&error, err);
	fprintf(stderr, "can't open zip archive '%s': %s\n", argv[1], zip_error_strerror(&error));
	zip_error_fini(&error);
	return -1;
    }
    if ((zs=zip_source_zip(za, z_in[z_in_count], idx, 0, start, len)) == NULL) {
	fprintf(stderr, "error creating file source from '%s' index '%" PRIu64 "': %s\n", argv[1], idx, zip_strerror(za));
	zip_close(z_in[z_in_count]);
	return -1;
    }
    if (zip_add(za, argv[0], zs) == -1) {
	fprintf(stderr, "can't add file '%s': %s\n", argv[0], zip_strerror(za));
	zip_source_free(zs);
	zip_close(z_in[z_in_count]);
	return -1;
    }
    z_in_count++;
    return 0;
}
开发者ID:hyunjinkwon,项目名称:gtk-win32,代码行数:31,代码来源:ziptool.c

示例6: add_to_zip

bool add_to_zip(const char *archive, const char *file, const char *name)
{
  struct zip *za;
  struct zip_source *zs;
  int err;

  if ((za=zip_open(archive, ZIP_CREATE, &err)) == NULL) {
    return false;
  }

  if ((zs=zip_source_file(za, file, 0, -1)) == NULL) {
    return false;
  }

  if (zip_add(za, name, zs) == -1) {
    zip_source_free(zs);
    return false;
  }

  if (zip_close(za) == -1) {
    return false;
  }

  return true;
}
开发者ID:quanghn,项目名称:visquajpegcompress,代码行数:25,代码来源:support_functions.cpp

示例7: zipruby_archive_add_buffer

static VALUE zipruby_archive_add_buffer(VALUE self, VALUE name, VALUE source) {
  struct zipruby_archive *p_archive;
  struct zip_source *zsource;
  char *data;
  size_t len;

  Check_Type(name, T_STRING);
  Check_Type(source, T_STRING);
  Data_Get_Struct(self, struct zipruby_archive, p_archive);
  Check_Archive(p_archive);

  len = RSTRING_LEN(source);

  if ((data = malloc(len)) == NULL) {
    rb_raise(rb_eRuntimeError, "Add file failed: Cannot allocate memory");
  }

  memset(data, 0, len);
  memcpy(data, RSTRING_PTR(source), len);

  if ((zsource = zip_source_buffer(p_archive->archive, data, len, 1)) == NULL) {
    free(data);
    rb_raise(Error, "Add file failed - %s: %s", RSTRING_PTR(name), zip_strerror(p_archive->archive));
  }

  if (zip_add(p_archive->archive, RSTRING_PTR(name), zsource) == -1) {
    zip_source_free(zsource);
    zip_unchange_all(p_archive->archive);
    zip_unchange_archive(p_archive->archive);
    rb_raise(Error, "Add file failed - %s: %s", RSTRING_PTR(name), zip_strerror(p_archive->archive));
  }

  return Qnil;
}
开发者ID:fjg,项目名称:zipruby,代码行数:34,代码来源:zipruby_archive.c

示例8: add_file

static int
add_file(int argc, char *argv[]) {
    zip_source_t *zs;
    zip_uint64_t start = strtoull(argv[2], NULL, 10);
    zip_int64_t len = strtoll(argv[3], NULL, 10);

    if (strcmp(argv[1], "/dev/stdin") == 0) {
	if ((zs=zip_source_filep(za, stdin, start, len)) == NULL) {
	    fprintf(stderr, "can't create zip_source from stdin: %s\n", zip_strerror(za));
	    return -1;
	}
    } else {
	if ((zs=zip_source_file(za, argv[1], start, len)) == NULL) {
	    fprintf(stderr, "can't create zip_source from file: %s\n", zip_strerror(za));
	    return -1;
	}
    }

    if (zip_add(za, argv[0], zs) == -1) {
	zip_source_free(zs);
	fprintf(stderr, "can't add file '%s': %s\n", argv[0], zip_strerror(za));
	return -1;
    }
    return 0;
}
开发者ID:hyunjinkwon,项目名称:gtk-win32,代码行数:25,代码来源:ziptool.c

示例9: r_io_zip_flush_file

int r_io_zip_flush_file(RIOZipFileObj *zip_file_obj) {
	int result = R_FALSE;
	struct zip * zipArch = r_io_zip_open_archive(zip_file_obj->archivename, zip_file_obj->flags, zip_file_obj->mode, zip_file_obj->rw);  

	if (!zipArch) {
		return result;
	}

	if (zip_file_obj) {
		struct zip_source *s = zip_source_buffer(zipArch, zip_file_obj->b, zip_file_obj->b->length, 0);
		if (s && zip_file_obj->entry != -1) {

			if (zip_replace(zipArch, zip_file_obj->entry, s) == 0)
				result = R_TRUE;

		}else if (s && zip_file_obj->name) {

			if (zip_add(zipArch, zip_file_obj->name, s) == 0) {

				zip_file_obj->entry = zip_name_locate(zipArch, zip_file_obj->name, 0);
				result = R_TRUE;
			}
		}
		if (s)
			zip_source_free(s);		

	}

	if (zipArch)
		zip_close(zipArch);

	return result;
}
开发者ID:jdukes,项目名称:radare2,代码行数:33,代码来源:io_zip.c

示例10: zip_fclose

ZIP_EXTERN int
zip_fclose(struct zip_file *zf)
{
    int ret;
    unsigned int i;
    
    if (zf->src)
	zip_source_free(zf->src);

    if (zf->za) {
        for (i=0; i<zf->za->nfile; i++) {
            if (zf->za->file[i] == zf) {
                zf->za->file[i] = zf->za->file[zf->za->nfile-1];
                zf->za->nfile--;
                break;
            }
        }
    }

    ret = 0;
    if (zf->error.zip_err)
	ret = zf->error.zip_err;

    free(zf);
    return ret;
}
开发者ID:360weboy,项目名称:php-src,代码行数:26,代码来源:zip_fclose.c

示例11: zipruby_archive_add_file

static VALUE zipruby_archive_add_file(int argc, VALUE *argv, VALUE self) {
  VALUE name, fname;
  struct zipruby_archive *p_archive;
  struct zip_source *zsource;

  rb_scan_args(argc, argv, "11", &name, &fname);

  if (NIL_P(fname)) {
    fname = name;
    name = Qnil;
  }

  Check_Type(fname, T_STRING);

  if (NIL_P(name)) {
    name = rb_funcall(rb_cFile, rb_intern("basename"), 1, fname);
  }

  Check_Type(name, T_STRING);
  Data_Get_Struct(self, struct zipruby_archive, p_archive);
  Check_Archive(p_archive);

  if ((zsource = zip_source_file(p_archive->archive, RSTRING_PTR(fname), 0, -1)) == NULL) {
    rb_raise(Error, "Add file failed - %s: %s", RSTRING_PTR(name), zip_strerror(p_archive->archive));
  }

  if (zip_add(p_archive->archive, RSTRING_PTR(name), zsource) == -1) {
    zip_source_free(zsource);
    zip_unchange_all(p_archive->archive);
    zip_unchange_archive(p_archive->archive);
    rb_raise(Error, "Add file failed - %s: %s", RSTRING_PTR(name), zip_strerror(p_archive->archive));
  }

  return Qnil;
}
开发者ID:fjg,项目名称:zipruby,代码行数:35,代码来源:zipruby_archive.c

示例12: main

int
main(int argc, char *argv[])
{
    const char *archive;
    const char *file;
    const char *name;
    zip_t *za;
    zip_source_t *zs;
    int err;
    FILE *fp;

    prg = argv[0];

    if (argc != 3) {
	fprintf(stderr, "usage: %s archive file\n", prg);
	return 1;
    }

    archive = argv[1];
    file = argv[2];
    
    if ((za=zip_open(archive, ZIP_CREATE, &err)) == NULL) {
	zip_error_t error;
	zip_error_init_with_code(&error, err);
	fprintf(stderr, "%s: can't open zip archive '%s': %s\n", prg, archive, zip_error_strerror(&error));
	zip_error_fini(&error);
	return 1;
    }

    if ((fp=fopen(file, "r")) == NULL) {
	fprintf(stderr, "%s: can't open input file '%s': %s\n", prg,
		file, strerror(errno));
	return 1;
    }

    if ((zs=zip_source_filep(za, fp, 0, -1)) == NULL) {
	fprintf(stderr, "%s: error creating file source for '%s': %s\n", prg,
		file, zip_strerror(za));
	return 1;
    }

    if ((name=strrchr(file, '/')) == NULL)
	name = file;

    if (zip_add(za, name, zs) == -1) {
	zip_source_free(zs);
	fprintf(stderr, "%s: can't add file '%s': %s\n", prg,
		file, zip_strerror(za));
	return 1;
    }

    if (zip_close(za) == -1) {
	fprintf(stderr, "%s: can't close zip archive '%s': %s\n", prg,
		archive, zip_strerror(za));
	return 1;
    }

    return 0;
}
开发者ID:JanX2,项目名称:libzip-git,代码行数:59,代码来源:add_from_filep.c

示例13: zipruby_archive_replace_function

static VALUE zipruby_archive_replace_function(int argc, VALUE *argv, VALUE self) {
  VALUE index, flags, mtime;
  struct zipruby_archive *p_archive;
  struct zip_source *zsource;
  struct read_proc *z;
  int i_index, i_flags = 0;

  rb_scan_args(argc, argv, "12", &index, &mtime, &flags);
  rb_need_block();

  if (TYPE(index) != T_STRING && !FIXNUM_P(index)) {
    rb_raise(rb_eTypeError, "wrong argument type %s (expected Fixnum or String)", rb_class2name(CLASS_OF(index)));
  }

  if (NIL_P(mtime)) {
    mtime = rb_funcall(rb_cTime, rb_intern("now"), 0);
  } else if (!rb_obj_is_instance_of(mtime, rb_cTime)) {
    rb_raise(rb_eTypeError, "wrong argument type %s (expected Time)", rb_class2name(CLASS_OF(mtime)));
  }

  if (!NIL_P(flags)) {
    i_flags = NUM2INT(flags);
  }

  Data_Get_Struct(self, struct zipruby_archive, p_archive);
  Check_Archive(p_archive);

  if (FIXNUM_P(index)) {
    i_index = NUM2INT(index);
  } else if ((i_index = zip_name_locate(p_archive->archive, RSTRING_PTR(index), i_flags)) == -1) {
    rb_raise(Error, "Replace file failed - %s: Archive does not contain a file", RSTRING_PTR(index));
  }

  if ((z = malloc(sizeof(struct read_proc))) == NULL) {
    zip_unchange_all(p_archive->archive);
    zip_unchange_archive(p_archive->archive);
    rb_raise(rb_eRuntimeError, "Replace failed at %d: Cannot allocate memory", i_index);
  }

  z->proc = rb_block_proc();
  rb_ary_push(p_archive->sources, z->proc);
  z->mtime = TIME2LONG(mtime);

  if ((zsource = zip_source_proc(p_archive->archive, z)) == NULL) {
    free(z);
    rb_raise(Error, "Replace failed at %d: %s", i_index, zip_strerror(p_archive->archive));
  }

  if (zip_replace(p_archive->archive, i_index, zsource) == -1) {
    zip_source_free(zsource);
    zip_unchange_all(p_archive->archive);
    zip_unchange_archive(p_archive->archive);
    rb_raise(Error, "Replace failed at %d: %s", i_index, zip_strerror(p_archive->archive));
  }

  return Qnil;
}
开发者ID:fjg,项目名称:zipruby,代码行数:57,代码来源:zipruby_archive.c

示例14: zip_name_locate

AbstractFSProvider::status_t ZIPProvider::ZIPHandle::writeFile(const FileName & file, const std::vector<uint8_t> & data, bool overwrite) {
	if (file.getFile().empty()) {
		return FAILURE;
	}

	bool replace = false;

	int index = zip_name_locate(handle, file.getPath().c_str(), 0);
	if (index != -1) {
		// File already exists.
		if (!overwrite) {
			return FAILURE;
		} else {
			replace = true;
		}
	}

	// Store data temporary because libzip writes data not until zip_close.
	tempStore.emplace_back(data);

	zip_source * source = zip_source_buffer(handle,
			tempStore.back().data(), static_cast<off_t>(tempStore.back().size()), 0);
	if (source == nullptr) {
		WARN(zip_strerror(handle));
		zip_source_free(source);
		tempStore.pop_back();
		return FAILURE;
	}

	int newIndex;
	if (replace) {
		newIndex = zip_replace(handle, index, source);
	} else {
		newIndex = zip_add(handle, file.getPath().c_str(), source);
	}
	if (newIndex == -1) {
		WARN(zip_strerror(handle));
		zip_source_free(source);
		tempStore.pop_back();
		return FAILURE;
	}
	dataWritten = true;
	return OK;
}
开发者ID:PADrend,项目名称:Util,代码行数:44,代码来源:ZIPProvider.cpp

示例15: zipruby_archive_add_io

static VALUE zipruby_archive_add_io(int argc, VALUE *argv, VALUE self) {
  VALUE name, file, mtime;
  struct zipruby_archive *p_archive;
  struct zip_source *zsource;
  struct read_io *z;

  rb_scan_args(argc, argv, "11", &name, &file);

  if (NIL_P(file)) {
    file = name;
    name = Qnil;
  }

  Check_IO(file);

  if (NIL_P(name)) {
    if (rb_obj_is_kind_of(file, rb_cFile)) {
      name = rb_funcall(rb_cFile, rb_intern("basename"), 1, rb_funcall(file, rb_intern("path"), 0));
    } else {
      rb_raise(rb_eRuntimeError, "Add io failed - %s: Entry name is not given", RSTRING(rb_inspect(file)));
    }
  }

  if (rb_obj_is_kind_of(file, rb_cFile)) {
    mtime = rb_funcall(file, rb_intern("mtime"), 0);
  } else {
    mtime = rb_funcall(rb_cTime, rb_intern("now"), 0);
  }

  Data_Get_Struct(self, struct zipruby_archive, p_archive);
  Check_Archive(p_archive);

  if ((z = malloc(sizeof(struct read_io))) == NULL) {
    zip_unchange_all(p_archive->archive);
    zip_unchange_archive(p_archive->archive);
    rb_raise(rb_eRuntimeError, "Add io failed - %s: Cannot allocate memory", RSTRING(rb_inspect(file)));
  }

  z->io = file;
  rb_ary_push(p_archive->sources, file);
  z->mtime = TIME2LONG(mtime);

  if ((zsource = zip_source_io(p_archive->archive, z)) == NULL) {
    free(z);
    rb_raise(Error, "Add io failed - %s: %s", RSTRING(rb_inspect(file)), zip_strerror(p_archive->archive));
  }

  if (zip_add(p_archive->archive, RSTRING_PTR(name), zsource) == -1) {
    zip_source_free(zsource);
    zip_unchange_all(p_archive->archive);
    zip_unchange_archive(p_archive->archive);
    rb_raise(Error, "Add io failed - %s: %s", RSTRING_PTR(name), zip_strerror(p_archive->archive));
  }

  return Qnil;
}
开发者ID:fjg,项目名称:zipruby,代码行数:56,代码来源:zipruby_archive.c


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