I am trying to find the position of the first header of a Central Directory file in a Zip file.
I read these: http://en.wikipedia.org/wiki/Zip_(file_format ) http://www.pkware.com/documents/casestudies/APPNOTE.TXT
As I see it, I can only view Zip data, identify by the title which section I am in, and then do this until I hit the Central Directory title. I would obviously read the file headers before and use the "compressed size" to skip the actual data, and not to loop through every byte in the file ...
If I do this, then I practically already know all the files and folders inside the Zip file, and in this case I no longer use the Central Directory.
As far as I understand, the purpose of Central Directory is to list file metadata and the position of the actual data in the Zip file, so you wonโt need to scan the entire file?
After reading the End Of Central Directory entry, Wikipedia says:
This ordering allows you to create a zip file in one pass, but it is usually unpacked the first time you read the central directory at the end.
How can I easily find the End of Central Directory? We need to remember that it may have a comment of arbitrary size, so I may not know how many bytes are at the end of the data stream in which it is located. Am I just scanning it?
PS I am writing a Zip file reader.
format zip
Tower
source share