Pieter Hoste
Pieter Hoste

Reputation: 587

extracting compressed file with boost::iostreams

I'm searching for a way to extract a file in c++ by using the boost::iostreams classes.

There is an example in the boost documentation. But it outputs the content of the compressed file to std::cout. I'm looking for a way to extract it to a file structure.

Does anybody know how to do that?

Thanks!

Upvotes: 4

Views: 9806

Answers (4)

Salgar
Salgar

Reputation: 7775

You probably don't want that library. You might want to look around for some others.

E.g. zziplib

Upvotes: 1

Jeff Hardy
Jeff Hardy

Reputation: 7662

Boost.IOStreams does not support compressed archives, just single compressed files. If you want to extract a .zip or .tar file to a directory tree, you'll need to use a different library.

Upvotes: 6

Stack Overflow is garbage
Stack Overflow is garbage

Reputation: 247919

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.

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.

Upvotes: 2

Harper Shelby
Harper Shelby

Reputation: 16585

Looks to me like the call to boost::iostreams::copy takes an ostream as the second parameter. Have you tried creating an ofstream with your output file name and using that?

Upvotes: 1

Related Questions