From: "Thomas Søndergaard" Date: 2002-07-10T01:07:04+09:00 Subject: Re: SV: SV: [ANN] Archive 0.2 > Basically, you need an Archive::Entry::Zip < Archive::Entry::Generic > that, given a io stream passed to initialize, reads and parses an > archive entry, and leaves the io cursor at the beginning of the next > one. If it can also output itself in Zip format again, you will be > able to pass entries to Archive::Writer for writing. > > Each Entry::XYZ has `parts': a Zip entry will most likely have a > `data' and a `header' part. Each part, in turn, has a `raw' and a > `parsed' attribute: `raw' points to the raw stuff as read from the > stream, `parsed' to a structure modifiable from code. You will > probably create an Archive::Entry::Zip::Header object that takes care > of receiving the Zip raw header, parse it, and initialize itself. The > data part will usually remain unparsed. Isn't this unnecessarily low level access - I don't see a need for exposing 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"? > > One nice thing of this design is that a mbox Entry can, for example, > implement a to_zip method. [...] I don't see any reason that mbox Entry should now about zip archives (to_zip method implies some knowledge). 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. > If you have any questions, just ask. I don't understand the interface completely. When you iterate over the items in the archive, will you generate Entry objects that contain the full uncompressed contents of the archive entry? That *might* be reasonable for mbox files but for zip and tar archives it seems unreasonable, especially for large archives. In rubyzip I have a ZipInputStream, which allows you to iterate over the contents of a zip archive, without having to read more than the header of the entries, that you do not care for. Like this: require 'zip' Zip::ZipInputStream.open("test/rubycode.zip") { |zipStream| while (entry = zipStream.getNextEntry) # entry contains the header information. If you want the # data read it from the zipStream as if it is an IO object puts "entry is #{entry.name}" puts "first 5 characters: '#{zipStream.read(5)}'" end } Don't you think this is better? The interface for iterating over the entries in the archive is a little raw, but that is only because ZipInputStream is not the preferred way of iterating over the contents of a zip file - instead ZipFile will read the central directory, so you can do this: Zip::ZipFile.foreach("test/rubycode.zip") { |entry| puts "entry is #{entry.name}" puts "first 5 characters: '#{entry.getInputStream { |is| is.read(5) }}'" } In either case, the data is only uncompressed and read on demand. > p.s.: Sorry to ask, isn't there some way to have your mail client set > correct References: or at least not modify the subject? I have been using Outlook Web Access from home to read mail, and there are no configuration options for the sending format. This one is send with Outlook Express - I hope the format is more agreeable to you. Thomas