From: Massimiliano Mirra Date: 2002-07-22T20:32:22+09:00 Subject: Re: SV: SV: [ANN] Archive 0.2 On Wed, Jul 10, 2002 at 07:10:28AM +0900, Thomas S�ndergaard wrote: > > > the raw header data. Also, I don't see a reason for treating the header > and > > > data parts as if they are somewhat similar (ie. parts). It seems like > > > "over-generalization"? > It's not that I think it will cause problems other than it is unnecessarily > complex for users of the API. Do you suggest adding a more abstracted interface to the archive entry? Sounds reasonable. > > > With a general archive interface it is > > > possible to do better, and write generic code for writing entries of one > > > archive to another regardless of the archive type. > > > > I have troubles figuring this. Could you please post a pseudo code > > example? > > I can try. This is what you wrote earlier: > > quote = < in = File.open("/var/mail/joe") > out = File.open("/home/joe/mails.zip") > > mbox = Archive::Reader::Mbox.new(in) > zip = Archive::Writer::Zip.new(out) > > mbox.scan do |entry| > zip.add(entry) > end > > The `add' method from Archive::Writer will see that we're trying to > write on a zip and that we have a Mbox::Entry#to_zip method, so will > use that, and we'll have converted from Mbox to Zip on the fly. > END_OF_QUOTE > > I think this example is basically fine, except your comment about how > zip.add(anEntry) will recognize that Mbox::Entry has a to_zip method. This > should not be necessary because Entry is (or should be) an object that > implements an interface that is common for all archive entries. Sorry, I wasn't clear. The pseudo code I was asking is the one for the solution you are proposing. > Ok. It seems to me that your design is heavily influenced by the structure > of tar.gz files, where the archive is compressed, instead of the archive > containing compressed entries I'm not sure I follow you here. The module I wrote is a .tar reader, not a .tar.gz reader. > (I think this is a short-coming in tar.gz > files). Are there other archive types that are as expensive to scan? What > other archives would benefit significantly from cached (to disk) maps of the > archive? mbox does. I know, I've been opening ruby-talk mboxes on a 486 lately. :-) > Or from the iterative access, where you have to iterate over > entries, even if you know the id or name of a particular entry that has your > interest. Every archive format that does not save a `table of contents', I guess. Massimiliano