Boost logo

Boost Users :

From: eg (egoots_at_[hidden])
Date: 2008-02-18 18:35:47


Mengda Wu wrote:
> Hi,
>
> I have a code block trying to output a series of gzip files. I wish
> to have all the files flushed after the block.
> But the files can only be flushed after exiting the whole program.
> The files still have zero size after I try to close them. I am using
> std::vector to store all the pointers to boost filtering_ostream.
> Can you help?
>
> //Open iostreams
>
> char filename[20];
> std::vector<boost::iostreams::filtering_ostream *> os_vector;
> for(i=0; i<4; i++)
> {
> sprintf(filename, "file_%d.gz", i );
> std::ofstream *of = new std::ofstream(filename, std::ios_base::binary);
> boost::iostreams::filtering_ostream* os = new
> boost::iostreams::filtering_ostream;
> os->push(boost::iostreams::gzip_compressor());
> os->push(*of);
> os_vector->push_back(os);
> }
>
> //Output something
> for(i=0; i<4; i++)
> {
> boost::iostreams::filtering_ostream* os = os_vector[i];
> os<<"Output something here" << std::endl;
> }
>
> //Close streams
> for(i=0; i<4; i++)
> {
> boost::iostreams::filtering_ostream* os = os_vector[i];
> os->strict_sync();
> os->pop();
> os->reset();
> }
>

I haven't tried out your sample...
but I am not sure if gzip filters are flushable?


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