Reputation: 425
boost::iostream bzip2_decompressor not decompressing file compressed by bzip2_compressor
Upvotes: 1
Views: 578
Reputation: 392911
Here's a simple self-contained example showing it to work:
#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);
}
}
On Coliru it shows it compresses itself to 331 bytes, and back again to stdout
Perhaps you are forgetting to flush, have non-binary, whitespace skipping. We can't tell without a SSCCE
Upvotes: 1