-
December 1st, 2011, 07:57 PM
#1
Using Boost for reading zip files
This is continuation of previous thread in my quest for getting something to read the zipped folders I have but since the methodology is different I decided to start a new thread.
I installed boost and ran a couple of example programs but this one which could have saved my day is not working:
Code:
#include <fstream>
#include <iostream>
#include <boost/iostreams/filtering_streambuf.hpp>
#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filter/gzip.hpp>
int main()
{
using namespace std;
ifstream file("hello.gz", ios_base::in | ios_base::binary);
filtering_streambuf<input> in;
in.push(gzip_decompressor());
in.push(file);
boost::iostreams::copy(in, cout);
}
The errors are:
Code:
1>c:\: error C2065: 'filtering_streambuf' : undeclared identifier
1>c:\: error C2065: 'input' : undeclared identifier
1>c:\: error C2065: 'in' : undeclared identifier
1>c:\: error C2065: 'in' : undeclared identifier
1>c:\: error C2228: left of '.push' must have class/struct/union
I just copied this code from boost website. Also, it does not give error with the headers as unrecognized headers at all.
So, where is this thing going wrong?
-
December 1st, 2011, 08:04 PM
#2
Re: Using Boost for reading zip files
Originally Posted by Learned
So, where is this thing going wrong?
The same thing that is wrong with this program:
Code:
#include <iostream>
int main()
{
cout << "Hello World"; // error -- cout undefined
}
In other words -- namespaces. Those definitions are in a namespace, they are not global names.
Regards,
Paul McKenzie
-
December 1st, 2011, 08:45 PM
#3
Re: Using Boost for reading zip files
Also, be aware that gzip is not the same thing as zip. gzip is a compression format used on the Internet for data transfer under the HTTP/1.1 protocol. zip is an archiving format for multiple files which may or may not be compressed.
Mike
-
December 1st, 2011, 09:20 PM
#4
Re: Using Boost for reading zip files
Originally Posted by MikeAThon
Also, be aware that gzip is not the same thing as zip. gzip is a compression format used on the Internet for data transfer under the HTTP/1.1 protocol. zip is an archiving format for multiple files which may or may not be compressed.
Mike
So, you mean boost is not suitable in reading .zip files?
-
December 1st, 2011, 09:38 PM
#5
Re: Using Boost for reading zip files
Originally Posted by Learned
So, you mean boost is not suitable in reading .zip files?
It is "suitable". The question is do you have a zip decompressor class that is compatible with the boost iostreams library?
Look at your code -- what makes it uncompress gzip files? Is it the boost::iostreams itself, or is it that gzip_decompressor()? It is the latter, and it's that plug-in that needs to be written or found somewhere. The boost::iostreams library is based on sources and sinks. In this case, the "source" would be a zipped file, and the "sink" is the uncompressed file.
So nothing stops boost::iostreams from decompressing zip files -- the issue is that do you have the "plug-in" to do it, if not, can you write one based on the "source" and "sink" paradigm?
Regards,
Paul McKenzie
Last edited by Paul McKenzie; December 1st, 2011 at 10:00 PM.
-
December 1st, 2011, 09:39 PM
#6
Re: Using Boost for reading zip files
Originally Posted by Learned
So, you mean boost is not suitable in reading .zip files?
Based on the sample code from the boost library (which mentions the file extension of .gz meaning gzip), and based on the name of the boost function gzip_decompressor(), I would say "no", the boost library is useless for decompression of .zip files
Mike
-
December 1st, 2011, 09:41 PM
#7
Re: Using Boost for reading zip files
Originally Posted by MikeAThon
Based on the sample code from the boost library (which uses the file extension of .gz meaning gzip), and based on the name of the boost function gzip_decompressor(), I would say "no", the boost library is useless for decompression of .zip files
Well, it isn't useless unless you write the decompressor that can be plugged into the boost::iostreams classes. Maybe someone has done it, I don't know. But it looks like the boost-iostreams authors left that as "homework" for someone else to do.
Regards,
Paul McKenzie
-
December 1st, 2011, 09:57 PM
#8
Re: Using Boost for reading zip files
Originally Posted by Learned
So, you mean boost is not suitable in reading .zip files?
Learned,
There are libraries that clearly state they read (and write) .zip archives and files, so if you see "gzip" as the only format it reads and not "zip", it isn't going to work, period.
Some of these zip libraries are free (InfoZip), while others, you have to pay for since they do much more. Please do a google search for these libraries.
Regards,
Paul McKenzie
-
December 1st, 2011, 10:42 PM
#9
Re: Using Boost for reading zip files
Originally Posted by Paul McKenzie
Some of these zip libraries are free (InfoZip), while others, you have to pay for since they do much more. Please do a google search for these libraries.
Learned - InfoZip is a good tip and a good find, and the suggestion to Google for other libraries is also a good one.
In addition, the latest version of the Windows SDK (?? I'm not completely sure of this -- the documentation is a bit vague and perhaps it's only available on a server development SDK??) exposes "Compression API Functions", see http://msdn.microsoft.com/en-us/library/hh437556.aspx
Originally Posted by MSDN
The native Compression API includes the following functions.
CloseCompressor
CloseDecompressor
Compress
CreateCompressor
CreateDecompressor
Decompress
QueryCompressorInformation
QueryDecompressorInformation
ResetCompressor
ResetDecompressor
SetCompressorInformation
SetDecompressorInformation
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|