Вопрос

According to the .ZIP File Format Specification (dated September 1, 2012), the overall .ZIP file format is as follows:

[local file header 1]
[encryption header 1]
[file data 1]
[data descriptor 1]
.
.
.
[local file header n]
[encryption header n]
[file data n]
[data descriptor n]
[archive decryption header]
[archive extra data record]
[central directory header 1]
.
.
.
[central directory header n]
[zip64 end of central directory record]
[zip64 end of central directory locator]
[end of central directory record]

I'm able to determine the presence/position of local file headers, central directory headers and the end of central directory record by means of the respective signatures.

How can I determine the existence or not of the encryption headers? Specifically, I want to know, for any given file with my zip, whether the file data immediately follows the local file header or not...

Это было полезно?

Решение

Section 4.4.4 of the specification explains it:

4.4.4 general purpose bit flag: (2 bytes)

   Bit 0: If set, indicates that the file is encrypted.

Therefore, and given that the encryption header has a fixed size, you know what to do ;)

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top