On Tuesday 09 July 2002 03:26 pm, Thomas S?ndergaard wrote:
> > I have seen zips in which the two headers each have (different)
> > extra fields.
>
> Is that allowed according to the spec? I just looked at pkware's
> Zip application note (appnote.txt), and I can't see anywhere that
> (any of) the fields in the local header are required to be
> identical to those in the central directory entry header.

Their spec isn't too helpful on the extra fields.

> It seems
> to me though, that they should - otherwise, which values would you
> use?  Those in the cdir entry or those in the local header?

Whichever you felt like, I guess. What I'd do is say that the CD ones 
would have precedence over the LD ones (because they were written 
later). But I've seen cases where the kind of field was different 
(perhaps ownership in the LD and timestamps in the CD).

I think you can see this in Info-Zip's zip files (this is from my 
zipinfo.pl that comes with the Archive::Zip module):

$LHMEMBER35 = bless( {
  "uncompressedSize" => 252,
  "versionMadeBy" => 23,
  "bitFlag" => 0,
  "fileName" => "xx.vim~",
  "crc32" => 100336855,
  "desiredCompressionMethod" => 8,
  "localExtraField" => 
"UT\t\0\3-\244\361;\233\325%=Ux\4\0\364\1\364\1",
  "desiredCompressionLevel" => -1,
  "externalFileAttributes" => "2176057344",
  "lastModFileDateTime" => 728594063,
  "compressionMethod" => 8,
  "cdExtraField" => "UT\5\0\3-\244\361;Ux\0\0",
  "diskNumberStart" => 0,
  "internalFileAttributes" => 1,
  "versionNeededToExtract" => 20,
  "fileComment" => "",
  "externalFileName" => "(xx.zip)",
  "compressedSize" => 111,
  "localHeaderRelativeOffset" => 41512,
  "fh" => $Archive::Zip::BufferedFileHandle,
  "fileAttributeFormat" => 3,
  "dataOffset" => 41570
}, 'Archive::Zip::ZipFileMember' );

Here both the CD and the LD have UT and Ux fields. And they're 
different.

>
> Ned, I just discovered that you wrote a popular Zip module for
> Perl.

Yes. That's the only reason I learned about the zip format. I also was 
one of the designers of the Microsoft Tape Format, but don't tell 
anyone...

> I'd be very interested in your comments about rubyzip. - or
> indeed your help ;-)

I'm trying to help <g>...

good luck,
-- 
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE