总体结构
[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]
local file header
offset |
description |
0 |
Local file header signature = 0x04034b50 (read as a little-endian number) |
4 |
Version needed to extract (minimum) |
6 |
General purpose bit flag |
8 |
Compression method |
10 |
File last modification time |
12 |
File last modification date |
14 |
CRC-32 of uncompressed data |
18 |
Compressed size (or 0xffffffff for ZIP64) |
22 |
Uncompressed size (or 0xffffffff for ZIP64) |
26 |
File name length (n) |
28 |
Extra field length (m) |
30 |
File name |
30+n |
Extra field |
30+n+m |
the end |
encryption header
TODO
data descriptor
offset |
description |
0 |
Optional data descriptor signature = 0x08074b50 |
0/4 |
CRC-32 of uncompressed data |
4/8 |
Compressed size |
8/12 |
Uncompressed size |
central directory header
offset |
description |
0 |
Central directory file header signature = 0x02014b50 |
4 |
Version made by |
6 |
Version needed to extract (minimum) |
8 |
General purpose bit flag |
10 |
Compression method |
12 |
File last modification time |
14 |
File last modification date |
16 |
CRC-32 of uncompressed data |
20 |
Compressed size (or 0xffffffff for ZIP64) |
24 |
Uncompressed size (or 0xffffffff for ZIP64) |
28 |
File name length (n) |
30 |
Extra field length (m) |
32 |
File comment length (k) |
34 |
Disk number where file starts |
36 |
Internal file attributes |
38 |
External file attributes |
42 |
Relative offset of local file header. This is the number of bytes between the start of the first disk on which the file occurs, and the start of the local file header. This allows software reading the central directory to locate the position of the file inside the ZIP file. |
46 |
File name |
46+n |
Extra field |
46+n+m |
File comment |
46+n+m+k |
the end |
end of central directory record
EOCD
offset |
description |
0 |
End of central directory signature = 0x06054b50 |
4 |
Number of this disk |
6 |
Disk where central directory starts |
8 |
Number of central directory records on this disk |
10 |
Total number of central directory records |
12 |
Size of central directory (bytes) |
16 |
Offset of start of central directory, relative to start of archive |
20 |
Comment length (n) |
22 |
Comment |
22+n |
the end |
EOCD64
offset |
description |
0 |
End of central directory signature = 0x06064b50 |
4 |
Size of the EOCD64 - 8 |
8 |
Version made by |
10 |
Version needed to extract (minimum) |
12 |
Number of this disk |
16 |
Disk where central directory starts |
20 |
Number of central directory records on this disk |
28 |
Total number of central directory records |
36 |
Size of central directory (bytes) |
44 |
Offset of start of central directory, relative to start of archive |
52 |
Comment (up to the size of EOCD64) |
52+n |
the end |
Refs
网友评论