UnZip.h/Zip.h C++压缩解压类
来源:互联网 发布:机顶盒软件下载 编辑:程序博客网 时间:2024/05/22 05:17
最近刚好用到,个人觉得还是比较好用的:
以下来自网络示例:
Example 1 - create a Zip file from existing files
// We place the file "simple.bmp" inside, but inside// the zipfile it will actually be called "znsimple.bmp".// Similarly the textfile.HZIP hz = CreateZip("simple1.zip",0);ZipAdd(hz,"znsimple.bmp", "simple.bmp");ZipAdd(hz,"znsimple.txt", "simple.txt");CloseZip(hz);
Example 2 - unzip a Zip file using the names it has inside it
HZIP hz = OpenZip("\\simple1.zip",0);ZIPENTRY ze; GetZipItem(hz,-1,&ze); int numitems=ze.index;// -1 gives overall information about the zipfilefor (int zi=0; zi<numitems; zi++){ ZIPENTRY ze; GetZipItem(hz,zi,&ze); // fetch individual details UnzipItem(hz, zi, ze.name); // e.g. the item's name.}CloseZip(hz);
Example 3- unzip from resource directly into memory
This technique is useful for small games, where you want to keep all resources bundled up inside the executable, but restricting the size.
Suppose we used a .rc with 1 RCDATA “file.zip” to embed the Zip file as a resource.
HRSRC hrsrc = FindResource(hInstance,MAKEINTRESOURCE(1),RT_RCDATA);HANDLE hglob = LoadResource(hInstance,hrsrc);void *zipbuf = LockResource(hglob);unsigned int ziplen = SizeofResource(hInstance,hrsrc);hz = OpenZip(zipbuf, ziplen, 0);ZIPENTRY ze; int i; FindZipItem(hz,"sample.jpg",true,&i,&ze);// that lets us search for an item by filename.// Now we unzip it to a membuffer.char *ibuf = new char[ze.unc_size];UnzipItem(hz,i, ibuf, ze.unc_size);...delete[] ibuf;CloseZip(hz);// note: no need to free resources obtained through Find/Load/LockResource
Example 4 - unzip chunk by chunk to a membuffer
Normally when you call UnzipItem(…), it gives the return-code ZR_OK. But if you gave it too small a buffer so that it couldn’t fit it all in, then it returns ZR_MORE.
char buf[1024]; ZRESULT zr=ZR_MORE; unsigned long totsize=0;while (zr==ZR_MORE){ zr = UnzipItem(hz,i, buf,1024); unsigned long bufsize=1024; if (zr==ZR_OK) bufsize=ze.unc_size-totsize; ... maybe write the buffer to a disk file here totsize+=bufsize;}
下载地址:Zip Utils
0 0
- UnZip.h/Zip.h C++压缩解压类
- linux zip 压缩命令 解压命令 unzip
- linux zip 压缩命令 解压命令 unzip
- linux zip 压缩命令 解压命令 unzip
- gzip,bzip2, xz , zip ,unzip ,解压,压缩;tar打包,解压。
- 压缩解压:tar zip unzip 7z|7za rar
- Centos中压缩(zip)和解压(unzip)命令
- linux zip/unzip err encoding压缩解压中文文件 乱码
- Centos中压缩(zip)和解压(unzip)命令
- Centos中压缩(zip)和解压(unzip)命令
- Liunx 分卷压缩和解压(zip和unzip)
- Linux下的压缩(zip)解压(unzip)缩命令
- Centos中压缩(zip)和解压(unzip)命令
- linux下压缩与解压(zip、unzip、tar)详解
- linux下压缩与解压(zip、unzip、tar)详解
- zip和unzip压缩解压指令 --排除目录
- Java 文件压缩和解压 Zip and Unzip
- linux下压缩与解压(zip、unzip、tar)详解
- .9图片处理报错Error: java.lang.RuntimeException: Crunching Cruncher ic_coupon2.9.png failed, see logs
- Jquery.velocity动画
- CSS规则的三种选择符和层叠样式规则
- 安卓学习笔记---fragment不断切换app崩溃的解决办法
- 可能是讲解Android事件分发最好的文章
- UnZip.h/Zip.h C++压缩解压类
- js 中导出excel 较长数字串会变成科学计数法
- 垂直外边距合并
- java代码性能优化
- arm-linux-ld命令 ld链接脚本
- superslide轮换图
- 51nod 1270 数组的最大代价【思维+Dp+滚动数组优化】
- 阿里云ECS Ubuntu14.04中无法安装MySQL
- 第七章 跨程序共享数据-探究内容提供器