boost :: iostream bzip2_decompressor不解压缩bzip2_compressor压缩的文件
答案 0 :(得分:1)
这是一个简单的自包含示例,显示它可以工作:
<强> Live On Coliru 强>
#include <iostream>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filter/bzip2.hpp>
#include <sstream>
namespace io = boost::iostreams;
int main()
{
std::stringstream ss;
{
io::filtering_stream<io::output> of;
of.push(io::bzip2_compressor{});
of.push(ss);
io::copy(std::cin, of);
}
std::cout << "Compressed input: " << ss.str().size() << " bytes\n";
ss.seekg(0ul);
{
io::filtering_stream<io::input> if_;
if_.push(io::bzip2_decompressor{});
if_.push(ss);
io::copy(if_, std::cout);
}
}
在Coliru上,它显示它将自身压缩为331个字节,然后再返回到stdout
也许你忘了刷新,有非二进制,空白跳过。没有SSCCE,我们无法分辨