Boost logo

Boost Users :

From: Tiago de Paula Peixoto (tiago_at_[hidden])
Date: 2005-10-30 17:03:22


Hello.

I've been experiencing the following problem with the gzip_compressor
filter: It always writes data down the stream, regardless if any data
has been written to the filtering_stream.

Consider the following program:

--------------------------------------------------------
#include <iostream>
#include <fstream>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filter/gzip.hpp>

using namespace std;
using namespace boost;

int main()
{
  ofstream file;
  file.open("hello.gz",
            ios_base::out | ios_base::app | ios_base::binary);
  iostreams::filtering_stream<boost::iostreams::output> stream;
  stream.push(iostreams::gzip_compressor());
  stream.push(file);
  return 0;
}
--------------------------------------------------------

If compiled as "test", the following behavior is observed:

$ ./test; ls -l hello.gz
-rw-r--r-- 1 count0 users 8 2005-10-30 19:51 hello.gz

$ ./test; ls -l hello.gz
-rw-r--r-- 1 count0 users 16 2005-10-30 19:51 hello.gz

$ ./test; ls -l hello.gz
-rw-r--r-- 1 count0 users 24 2005-10-30 19:51 hello.gz

That is, it always adds 8 bytes to the file, despite the fact that
nothing was written to the stream. To top things off, the data inside
the file isn't even recognizable by gzip:

$ gunzip hello.gz

gunzip: hello.gz: not in gzip format

When bzip2_compressor is used, this strange behavior doesn't happen, and
the file remains with 0 bytes.

I guess this is a bug, right?

I'm using boost 1.33.0 with GCC 4.0.1 in a GNU/Linux system.

Thanks for any help.

-- 
Tiago de Paula Peixoto <tiago_at_[hidden]>



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