The code works for me. Thanks,

Mengda

2008/2/21, eg <egoots@gmail.com>:
Mengda Wu wrote:
> Hi,
>

>    I am trying to save gzip files and close them in my program without
> quitting it. And I would like
> to read these files using another program at the same time. The problem
> is I cannot access the gzip
> files unless I quit my program. Do you know whether I can properly save
> and close the gzip files with
> boost iostreams?
>


The following works for me when I call it in a function using boost
1.33.1 (in Windows XP):

        using namespace std;
        namespace io = boost::iostreams;

        std::ifstream ifs(infile, std::ios_base::in | std::ios::binary);
        io::filtering_ostream out;

        out.push(io::gzip_compressor());
        out.push( io::file_sink(outfile, ios_base::out | ios_base::binary));
        out << ifs.rdbuf();
        ifs.close();
        out.flush();
        out.reset();

// After the reset, the output file is closed.