ZIPの規格
最新の規格書
さすがに最初にこれを読むのはきつい
ほかの解説を読んでだいたいの構造を知ってから、この仕様書で正確な定義を知るのがいいと思う
2024-08-21 読めるようになったtakker.icon
メモリ配置の図解を見たいときに参照するとよい
2024-08-21 fflateを題材にしながら規格を読み進めている だいぶ理解できた
table:general structure
local file descriptor N個
Archive decryption header 0~1個 only v6.2 or greater
Archive extra data record 0~1個 only v6.2 or greater
Central directory 1個
table: Local file descriptor
File data 1個
table:Local file header
offset in byte
0 signature 0x50
1 0x4b
2 0x03
3 0x04
4 Version
5
6 Flags
7
8 Comression method
9
11
13
14 CRC-32 checksum
15
16
17
18 Comressed size
19
20
21
22 Uncompressed size
23
24
25
26 Filename length
27
28 Extra field length
29
30 Filename
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48 Extra filed
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
Version
6.2なら0x3E00と格納される
62=16*3+14*1=3E
table:Flags
offset in bits
0 encrypted file
1 compression option
2 compression option
3 data descriptor
4 enhanced deflation
5 compressed patched data
6 strong encryption
7 unused
8 unused
9 unused
10 unused
11 language encoding
12 reserved
13 masc header values
14 reserved
15 reserved
magic numberは0xdebb20e3(little endian)
data descriptorがtrueなら、Local file headerのCRC-32 checksum, Compressssed size, Uncompressed sizeは0になる
table:Compression method
value (little endian)
0x0000 no compression
0x0100 shrunk
0x0200 reduced with compression factor 1
0x0300 reduced with compression factor 2
0x0400 reduced with compression factor 3
0x0500 reduced with compression factor 4
0x0600 imploded
0x0700 reserved
0x0800 deflated
0x0900 enhanced deflated
0x0a00 PKWare DCL imploded
0x0b00 reserved
0x0c00 compressed using BZIP2
0x0d00 reserved
0x0e00 LZMA
0x0f00 reserved
0x1000 reserved
0x1100 reserved
0x1200 compressed using IBM TERSE
0x1300 IBM LZ77 z
0x6200 PPMd version I, Rev 1
table:Data descriptor
offset in bytes
0 CRC-32 checksum
1 Compressed size
2
3
4
5
6
7
8 Uncompressed size
9
10
11
table:Central directory
table:End of central directory record
offset in bytes
0 Signature 0x50
1 0x4b
2 0x05
3 0x06
4 Disk Number
5
6 Disk # w/cd
7
8 Disk entries
9
10 Total entries
11
12 Central directory size
13
14
15
16 Offset of cd wrt to starting disk
17
18
19
20 Comment length
21
22 ZIP file comment
23
24
25
26
27
28
29
30
31
/で終わる空のファイルとして扱われるようだ
directory配下にあるファイルは、ファイルパスがfilenameとして格納される