On Tue, Jul 09, 2002 at 11:35:48PM +0900, Ned Konz wrote:
> > 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.
> 
> So the assumption is that headers precede data?

No, the assumption (at least without modifying Reader::XYZ#scan) is
that archives are sequences of blocks and each block is an entry.  How
to deal with how an entry is laid out internally is a task of
Entry::XYZ#new.

> Note that the Zip format usually has two headers per file: one before 
> the file data, and one at the very end of the file.
> 
> So ideally the archive reader would get the stream first and read the 
> end directory if the stream was seekable, then position before the 
> first header.
> 
> Then as individual pre-file headers were read, their information could 
> be merged as appropriate with the end-of-zip (Central Directory) 
> information.
 
So the way to make a reader (note that Thomas was interested in making
a proxy to his code, though) would be to not just inherit the scan
method from Archive::Reader::Generic, but instead add code that goes
to the end of the files first, collects the header it needs, goes back
to the beginning, and creates each entry with entry = Entry.new(io,
extra_data), extra_data being the collected information.

It breaks the regularity of entry = Entry.new(io), but if that's the
only way...


Massimiliano