I am trying to decompress a .7z (or .xz or .lzma) file using
- boost library 1.67.0 on a Linux platform
with the following code:
vector<T> readFromCompressedFile(string input_file_path, string output_file_path)
{
namespace io = boost::iostreams;
stringstream strstream;
ifstream file(input_file_path.c_str(), ios_base::in | ios_base::binary);
ofstream out(output_file_path, ios_base::out | ios_base::binary);
boost::iostreams::filtering_istream in;
in.push(io::lzma_decompressor());
in.push(file);
io::copy(in, out);
cout<<strstream.str()<<endl;
The code compiles, but I get a runtime exception (lzma_error) raised by the copy method
warning: GDB: Failed to set controlling terminal: Operation not permitted
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::iostreams::lzma_error> >'
what(): lzma error: iostream error
I tried with no luck to use a filtering_streambuf filter with a chunk of code very similar to the one for the gzip example
https://www.boost.org/doc/libs/1_67_0/libs/iostreams/doc/classes/gzip.html#examples
However I am able to decompress a file compressed with gzip and with the above code. It seems that the issue is limited to LZMA algorithm.
Anyone with the same issue? Any ideas?
Thank you