gzip demo
来源:互联网 发布:ubuntu安装jdk eclipse 编辑:程序博客网 时间:2024/06/04 17:42
#include <stdio.h>#include <zlib.h>// Demoint decompress_file(char *infilename, char *outfilename){ int num_read = 0; char buffer[128]; gzFile infile = gzopen(infilename, "rb"); FILE *outfile = fopen(outfilename, "wb"); if (!infile || !outfile) { return -1; } while ((num_read = gzread(infile, buffer, sizeof(buffer))) > 0) { fwrite(buffer, 1, num_read, outfile); } gzclose(infile); fclose(outfile);}int compress_file(char *infilename, char *outfilename){ int num_read = 0; char inbuffer[128]; FILE *infile = fopen(infilename, "rb"); gzFile outfile = gzopen(outfilename, "wb"); if (!infile || !outfile) { return -1; } while ((num_read = fread(inbuffer, 1, sizeof(inbuffer), infile)) > 0) { total_read += num_read; gzwrite(outfile, inbuffer, num_read); } fclose(infile); gzclose(outfile);}int main(int argc, char **argv){ compress_file(argv[1],argv[2]); decompress_file(argv[2],argv[3]);}
本文出自 “一路风景” 博客,请务必保留此出处http://which.blog.51cto.com/7179876/1602544
阅读全文
0 0
- gzip demo
- gzip
- gzip
- GZIP
- gzip
- gzip
- gzip
- gzip
- gzip
- gzip
- GZIP
- gzip
- Gzip
- gzip
- gzip
- 【C/C++】C实现gzip格式的压缩与解压Demo
- gzip -- 支持gzip文件
- gzip相关
- python 后台运行问题
- const 类型
- 错误:Component is part of the declaration of 2 modules
- socket shutdown
- 服务器搭建实践(一)centos7使用nginx+tomcat实现负载均衡
- gzip demo
- maven项目右键没有maven菜单选项
- linux samba 配置 tag
- 购物车Recyclerview
- linux 下获取程序启动路径
- 你还在在淘宝天猫上原价购买商品么?
- 深入浅出JMS(三)--ActiveMQ简单的HelloWorld实例
- OS开发实践:用Swift和Core Animatoin创建圆形图片加载动画
- 解析[ ]