我无法获得boost :: iostreams的zlib过滤器忽略gzip头......似乎将zlib_param的default_noheader设置为true,然后调用zlib_decompressor()产生'data_error'错误(错误的头部检查)。这告诉我zlib仍然期望找到标题。 有没有人获得boost :: iostreams :: zlib解压缩数据而不用头文件?我需要能够读取和解压缩没有双字节标题的文件/流。任何援助将不胜感激。boost :: iostreams :: zlib :: default_noheader似乎被忽略
这里是由升压::提供的样本程序的修改版本的iostream :: zlib的文档:
#include <fstream>
#include <iostream>
#include <boost/iostreams/filtering_streambuf.hpp>
#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filter/zlib.hpp>
int main(int argc, char** argv)
{
using namespace std;
using namespace boost::iostreams;
ifstream ifs(argv[1]);
ofstream ofs("out");
boost::iostreams::filtering_istreambuf in;
zlib_params p(
zlib::default_compression,
zlib::deflated,
zlib::default_window_bits,
zlib::default_mem_level,
zlib::default_strategy,
true
);
try
{
in.push(zlib_decompressor(p));
in.push(ifs);
boost::iostreams::copy(in, ofs);
ofs.close();
ifs.close();
}
catch(zlib_error& e)
{
cout << "zlib_error num: " << e.error() << endl;
}
return 0;
}
我知道我的测试数据不坏;我写了一个小程序在测试文件中调用gzread();它成功解压缩...所以我很困惑,为什么这不起作用。
在此先感谢。
-ICE