Boost logo

Boost Users :

From: Jonathan Turkanis (technews_at_[hidden])
Date: 2005-11-15 21:53:42


Christian Henning wrote:
> Hi there I just have a simple question regarding the format of a zlib
> archive. Somehow WinRar cannot read the archive.

What format does WinRar expect? The zlib_compressor compresses data using the
ZLIB format (http://www.ietf.org/rfc/rfc1950.txt).

> If I use the simple
> example application provided in the zlib distribution WinRar is able
> to read it.

Which sample application?

> This makes me wondering what difference is in the archive
> generated by boost::iostreams?

> Here is my example code which works fine. I using VC7.1 and Boost 1.33
>
> #include <iostream>
>
> #define BOOST_IOSTREAMS_NO_LIB
>
> #include <boost/iostreams/device/file.hpp>
> #include <boost/iostreams/filtering_stream.hpp>
> #include <boost/iostreams/filter/zlib.hpp>
>
> namespace io = boost::iostreams;
>
> int _tmain(int argc, _TCHAR* argv[])
> {
> {
> io::filtering_ostream out;
> out.push( io::zlib_compressor() );
> out.push( io::file_sink( "hello.zip" ));

This might be the problem. zlib_compressor does not write data in the "ZIP"
archive format
(http://www.pkware.com/business_and_developers/developer/appnote/). You can use
zlib_[de]compressor to implement a zip archiver, but if you try to open a file
in the ZLIB format with a utility that expects a ZIP file, it won't work.

I may add support for zip files eventually, but I haven't decided on an
interface, and I'm not even sure whether it should go in the iostreams library
or in a new library.

>
> out << "Hello boost::iostreams";
>
> //close the file
> }
>
> io::filtering_istream in;
> in.push( io::zlib_decompressor() );
> in.push( io::file_source( "hello.zip" ));
>
> std::string strMessage;
>
> std::getline( in, strMessage );
>
> std::cout << strMessage << std::endl;
>
> return 0;
> }
>
> Besides the problem, seems that boost::iostream is an amazing lib and
> a huge contribution for the C++ community.

Thanks!

> Thanks,
> Christian

-- 
Jonathan Turkanis
www.kangaroologic.com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net