Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

What header information to use?

3 views
Skip to first unread message

Darius Blaszijk

unread,
Oct 16, 2006, 2:31:14 PM10/16/06
to
When reading data from a zipfile, what header information should be used to
get the length of the file data? I currently use information from the local
file header, but when reading data from an odt file (open office project
file, renamed zipfile actually) I found out that the LFH information in that
file was invalid (CRC=$0 etc). Should I simply switch to using the CDFH
information? The appnote doesn't explicitly mention under what conditions I
should use what information.

TIA Darius

Mark Adler

unread,
Oct 16, 2006, 11:49:00 PM10/16/06
to
Darius Blaszijk wrote:
> I found out that the LFH information in that
> file was invalid (CRC=$0 etc). Should I simply switch to using the CDFH
> information?

Both the local and central information will be correct in a valid zip
file, but the local information may be stored *after* the entry in a
"data descriptor" instead of in the local header. This is noted by a
bit in the local header flags, in which case the lengths and crc in the
local header are set to zero.

mark

Darius Blaszijk

unread,
Oct 17, 2006, 3:08:18 AM10/17/06
to
That's it yes, the CDFH general purpose bit has a value of 0x0008.

Thanks Mark, Darius

"Mark Adler" <mad...@alumni.caltech.edu> schreef in bericht
news:1161056940.4...@m73g2000cwd.googlegroups.com...

jasen

unread,
Oct 21, 2006, 2:32:54 AM10/21/06
to
On 2006-10-16, Darius Blaszijk <dhkbl...@zeelandnet.nl> wrote:
> When reading data from a zipfile, what header information should be used to
> get the length of the file data?

you could use the data itself.... the end is unambiguous. the local header won't
have valid data or CRC if the file was written in stream mode

Bye.
Jasen

0 new messages