[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    Re: Images and Stores
From:       Thomas Zander <zander () planescape ! com>
Date:       2002-01-26 12:16:02
[Download RAW message or body]

On Sat, Jan 26, 2002 at 12:21:28PM +0100, David Faure wrote:
> On Saturday 26 January 2002 11:52, Clarence Dang wrote:
> > 2. Is it possible to have more than one file open in a store because at the \
> > moment, I have to do this:
> 
> Hehe, I can see Werner smiling from here - we discussed this in length.
> 
> > KoStore *outfile = new KoStore (outfilename, KoStore::Write);
> > 
> > outfile->open ("root");				// maindoc.xml
> > outfile->write ("Lots and lots of text", length);
> > outfile->close ();
> > 
> > outfile->open ("tar:/pictures/picture0.bmp");	// pictures/picture0.bmp
> > outfile->write ("raw binary, bitmap data", length);
> > outfile->close ();
> > 
> > outfile->open ("tar:/pictures/picture1.bmp");	// pictures/picture1.bmp
> > outfile->write ("more raw binary, bitmap data", length);
> > outfile->close ();
> > 
> > delete (outfile);
> > 
> > Is this correct?
> Yes.
> 
> > I'm finding it rather inconvenient to only be able to have one file in the store \
> > open at a time. e.g. suppose I was importing some text and then there was a \
> > picture in the document -- with the current scheme, I would have to store the \
> > contents of the picture in a buffer and then output the picture, only after I was \
> > finished with the text?
> Yes.
> Please keep in mind that the underlying contents are a gzipped file.
> How on earth would one implement "being able to write at two positions 
> of the gzipped file at the same time" ? That's impossible.
> The only way to provide the API you're requesting would be to buffer _everything_ 
> in memory (all files to be written to the archive), and then write it all at once.
> This would eat memory like an oger.
> That's why the buffering has to be done in the application (or filter) : at least
> it can try to minimize the amount of buffering required, since it knows when it
> has finished with a given file inside the archive, which can then be written
> for real and the memory for it can be discarded.

Fast solution is to create an KoBufferedStore:public KOStore object that does 
just this. And have 
   pictureStore = outfile->getBufferedFile(outFilename);
to create a bufferedStore object for you.
If you close the buffered store like you should, then the close of the
KoStore object could loop over all closed buffered stores and store them
to the output file sequencially.
  pictureStore->close(); // does nothing but set a boolean
  outfile->close();      // closes current stream, writes pictureStore to tgz

Just an idea... 

-- 
Thomas Zander                                            zander@earthling.net
The only thing worse than failure is the fear of trying something new


[Attachment #3 (application/pgp-signature)]
_______________________________________________
koffice-devel mailing list
koffice-devel@mail.kde.org
http://mail.kde.org/mailman/listinfo/koffice-devel

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic