Re: code to list contents of zip files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Prasanta Sadhukhan wrote:

> Is it possible to output the content of a particular file from a zip file?
> For example, in the attached ziptest.c I want to get the contents of a 
> particular file Class3.class from testclasses.zip into a buffer, can 
> anyone point out what I need to change in the code?

Iterate over the files until you find the right one. Either start by
locating the first local file header, then each subsequent one, or
locate the central directory and iterate over the file headers which
are stored there.

For the first method, given the offset of one local file header, the
next one should be located 30 + "file name length" + "extra field length"
+ "compressed size" + 12 bytes further on.

For the second method, the offset from one entry to the next is
46 + "file name length" + "extra field length" + "file comment length".

The start of the central directory can be found from the end of
central directory record, which is at the end of the file. The length
is variable, so you have to scan backwards for the signature (50 4b 05
06), then verify that the offset is 22 + "ZIP file comment length"
bytes before the end of the file).

-- 
Glynn Clements <glynn@xxxxxxxxxxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux