【发布时间】:2018-04-27 23:44:07
【问题描述】:
我正在尝试使用
解压缩 .7z(或 .xz 或 .lzma)文件- 在 Linux 平台上提升库 1.67.0
使用以下代码:
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;
代码编译,但我得到了复制方法引发的运行时异常(lzma_error)
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
我尝试使用与 gzip 示例中的代码非常相似的部分代码的 filtering_streambuf 过滤器,但没有成功
https://www.boost.org/doc/libs/1_67_0/libs/iostreams/doc/classes/gzip.html#examples
但是,我能够解压缩使用 gzip 和上述代码压缩的文件。 看来问题仅限于 LZMA 算法。
有同样问题的人吗?有什么想法吗?
谢谢
【问题讨论】:
标签: c++ boost compression lzma