Boost logo

Boost Users :

Subject: Re: [Boost-users] Read/write with gzip
From: Ted Byers (r.ted.byers_at_[hidden])
Date: 2011-04-27 12:27:30


On Tue, Apr 26, 2011 at 8:54 PM, Anders Knudby <knudby_at_[hidden]> wrote:

> 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
> elsewhere).
>
> #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.push(io::gzip_compressor());
> out.push(io::file_descriptor_sink("c:/outfile.gz"));
> out.write (memblock, size);
>
>
> Is there a reason not to invoke the stream's member function 'close' at
this point? You are, after all, reopening the same file later in your
program.

Cheers

Ted



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