char buf[1024*1024*16];
gzFile *fi = (gzFile *)gzopen("file.gz","rb");
gzrewind(fi);
while(!gzeof(fi))
{
int len = gzread(fi,buf,sizeof(buf));
//buf contains len bytes of decompressed data
}
gzclose(fi);
char buf[1024*1024*16];
gzFile *fi = (gzFile *)gzopen("file.gz","rb");
gzrewind(fi);
while(!gzeof(fi))
{
int len = gzread(fi,buf,sizeof(buf));
//buf contains len bytes of decompressed data
}
gzclose(fi);
If you can use boost, I would recommend the boost iostreams API. See the boost iostreams tutorial. It has support for GZIP and BZIP2 compressors and decompressors.
发布评论
评论(3)
用于解压:
用于压缩
For decompression:
For compression
请仔细阅读本文。该信息已在此处提供:
这是即使在谷歌上也显示的第一个链接。
Please read through this. The information is already available here:
That is the first link that shows up even on google.
如果你可以使用 boost,我会推荐 boost iostreams API。请参阅
Boost iostreams 教程。它支持 GZIP 和 BZIP2 压缩器和解压缩器。
If you can use boost, I would recommend the boost iostreams API. See the
boost iostreams tutorial. It has support for GZIP and BZIP2 compressors and decompressors.