ファイル形式 File Format Spec

無圧縮のための ZIP

基本的にビッグエンディアンみたい.

ファイル全体概略

[local file header1]
[file data 1]
.
.
.
[local file header n]
[file data n]
[central directory]
[end of central directory record] 

local file header

local file header signature 4 bytes (0x04034b50) 
version needed to extract 2 bytes (普通は0x000Aかな)
general purpose bit flag 2 bytes (普通は0x0000)
compression method 2 bytes (普通は0x0000)
last mod file time 2 bytes 上位5ビットが時間(24時間),次6ビットが分,残り5ビットが秒の半分?
last mod file date 2 bytes 下位5ビットが日,その次4ビットが月,残りの上位ビットが年をあらわすみたい
年は1980年が0?
crc-32 4 bytes 
compressed size 4 bytes 
uncompressed size 4 bytes 
file name length 2 bytes 
extra field length 2 bytes  
file name (variable size) 
extra field (variable size) 

Central directory structure

[file header 1]
.
.
.
[file header n]

File header:
central file header signature 4 bytes (0x02014b50) 
version made by 2 bytes 
version needed to extract 2 bytes 
general purpose bit flag 2 bytes 
compression method 2 bytes 
last mod file time 2 bytes 
last mod file date 2 bytes 
crc-32 4 bytes 
compressed size 4 bytes 
uncompressed size 4 bytes 
file name length 2 bytes 
extra field length 2 bytes 
file comment length 2 bytes 
disk number start 2 bytes 
internal file attributes 2 bytes 
external file attributes 4 bytes 
relative offset of local header 4 bytes 
file name (variable size) 
extra field (variable size) 
file comment (variable size) 

End of central dir record

end of central dir signature 4 bytes (0x06054b50) 
number of this disk 2 bytes 
number of the disk with the start of the central directory 2 bytes 
total number of entries in the central directory on this disk 2 bytes 
total number of entries in the central directory 2 bytes 
size of the central directory 4 bytes 
offset of start of central directory
with respect to the starting disk number 4 bytes 
.ZIP file comment length 2 bytes 
.ZIP file comment (variable size) 

参考:http://www.pkware.com/products/enterprise/white_papers/appnote.html


Home