views:

839

answers:

5

Hi

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!

+1  A: 

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?

Harper Shelby
Jep, already tried that, that creates just one file with a bunch of garbage inside it, it doesn't create a complete file structure...
Pieter Hoste
What does "a complete file structure" mean?Is it actually producing the correct output on cout? If so then it should be easy to get this to work...
bacar
+1  A: 

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.

jalf
+2  A: 

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.

Jeff Hardy
+1  A: 

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

E.g. zziplib

Salgar
A: 

zziplib is read-only api for zipfiles.

Sachin