Boost logo

Boost Users :

Subject: [Boost-users] Read/write with gzip
From: Anders Knudby (knudby_at_[hidden])
Date: 2011-04-26 20:54:19

Hello, I previously managed to write data to a gzipped file using the
following code structure (it's an example of course, the "memblock" is
actually filled with real data and the real filename is specified

#include <boost/iostreams/filtering_streambuf.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filter/gzip.hpp>
#include <boost/iostreams/device/file_descriptor.hpp>
#include <boost/filesystem.hpp>

namespace io = boost::iostreams;

int size = 1000;
char* memblock = new char [size];

io::filtering_ostream out;
out.write (memblock, size);

That works fine. I would now like to read these data again. I imagined I
could do something like the following (using the same #include statements
etc. as above):

int size = 1000;
char* memblock = new char [size];

io::filtering_istream in;
in.push(io::file_descriptor_source("c:/outfile.gz")); (memblock, size);

That complies and runs, but it doesn't give me the real data back. What am I
doing wrong?


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at