Boost logo

Boost Users :

From: Mengda Wu (phdggg_at_[hidden])
Date: 2008-02-21 03:04:04


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?

Thanks,
Mengda

2008/2/18, eg <egoots_at_[hidden]>:
>
> 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