简体   繁体   English

使用boost :: iostreams提取压缩文件

[英]extracting compressed file with boost::iostreams

I'm searching for a way to extract a file in c++ by using the boost::iostreams classes. 我正在寻找一种使用boost :: iostreams类在c ++中提取文件的方法。

There is an example in the boost documentation . boost文档中有一个示例。 But it outputs the content of the compressed file to std::cout. 但它将压缩文件的内容输出到std :: cout。 I'm looking for a way to extract it to a file structure. 我正在寻找一种方法将其提取到文件结构。

Does anybody know how to do that? 有谁知道怎么做?

Thanks! 谢谢!

Boost.IOStreams does not support compressed archives, just single compressed files. Boost.IOStreams不支持压缩存档,只支持单个压缩文件。 If you want to extract a .zip or .tar file to a directory tree, you'll need to use a different library. 如果要将.zip或.tar文件解压缩到目录树,则需要使用其他库。

The example in the documentation shows how to decompress the file and push the result to another stream. 文档中的示例显示了如何解压缩文件并将结果推送到另一个流。

If you want the output to be directed to an in-memory array instead, you can use a stream of type boost::iostreams::stream<boost::iostreams::array_source> instead. 如果您希望将输出定向到内存数组,则可以使用boost::iostreams::stream<boost::iostreams::array_source>类型的boost::iostreams::stream<boost::iostreams::array_source>

That is basically a stream-wrapper around an array. 这基本上是一个数组的流包装器。

I'm not sure what you mean when you say you want the output in "a file structure" though. 当你说你想要“文件结构”中的输出时,我不确定你的意思。

Looks to me like the call to boost::iostreams::copy takes an ostream as the second parameter. 在我看来,调用boost :: iostreams :: copy会将ostream作为第二个参数。 Have you tried creating an ofstream with your output file name and using that? 您是否尝试使用输出文件名创建一个ofstream并使用它?

You probably don't want that library. 你可能不想要那个库。 You might want to look around for some others. 您可能想要四处寻找其他人。

Eg zziplib 比如zziplib

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM