Boost logo

Boost Users :

From: Jonathan Turkanis (technews_at_[hidden])
Date: 2005-11-16 12:18:28


Christian Henning wrote:
> When I use this little test program, taken from the zlib examples.
> WinRar doesn't have any problem opening it. The generated file
> "chh.gz" is 26 bytes.
>
> int main()
> {
> gzFile file;
>
> file = gzopen( "chh.gz", "wb");

Okay, you're writing data in the gzip format, which has a different headder and
footer than the zlib format, even though the body of the compressed data is the
same. For this, you should be using the gzip filters:
www.boost.org/libs/iostreams/doc/index.html?path=4.2.2.11.

> gzputc(file, 'h');
> gzputs(file, "ello" );
>
> gzseek(file, 1L, SEEK_CUR); /* add one zero byte */
>
> gzclose(file);
>
> return 0;
> }
>
> Using the iostreams I think, and I might be wrong, should generate the
> same file using this test program:
>
> int main()
> {
> io::filtering_ostream out;
> out.push( io::zlib_compressor() );

try:

     out.push( io::gzip_compressor() );

> out.push( io::file_sink( "chh.gz", std::ios::binary ));
>
> out << "hello";
>
> return 0;
> }
>
> Here the file is 13 bytes. So I guess the header or footer is wrong.
>
> Greets,
> 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