zip文件格式说明
来源:互联网 发布:中控和矩阵 编辑:程序博客网 时间:2024/04/28 09:50
zip文件由三部分组成:压缩的文件内容源数据、压缩的目录源数据、目录结束标识结构
1、 压缩的文件内容源数据:
记录着压缩的所有文件的内容信息,其数据组织结构是对于每个文件都由file header 、file data、datadescriptor三部分组成。
1)File header:用于标识该文件的开始,结构说明如下:
Offset
Bytes
Description
译
0
4
Local file header signature = 0x04034b50 (read as a little-endian number)
文件头标识,值固定(0x04034b50)
4
2
Version needed to extract (minimum)
解压文件所需 pkware最低 版本
6
2
General purpose bit flag
通用位标记
8
2
Compression method
压缩方法
10
2
File last modification time
文件最后修改时间
12
2
File last modification date
文件最后修改日期
14
4
CRC-32
说明采用的算法。
18
4
Compressed size
压缩后的大小。
22
4
Uncompressed size
非压缩的大小。
26
2
File name length (n)
文件名长度
28
2
Extra field length (m)
扩展区长度
30
n
File name
文件名
30+n
m
Extra field
扩展区
2)file data :相应压缩文件的源数据。
3)data descriptor:用于标识该文件压缩结束,该结构只有在相应的header中通用标记字段的第3位设为1时才会出现,紧接在压缩文件源数据后。这个数据描述符只用在不能对输出的 ZIP 文件进行检索时使用。例如:在一个不能检索的驱动器(如:磁带机上)上的 ZIP 文件中。如果是磁盘上的ZIP文件一般没有这个数据描述符。
结构说明如下:
Data descriptor
Offset
Bytes
Description[18]
译
0
4
Local file header signature = 0x08074b50
本地header标记
4
4
CRC-32
CRC-32
8
4
Compressed size
压缩后大小
12
4
Uncompressed size
非压缩的大小
2、 压缩的目录源数据
对于待压缩的目录而言,每一个子目录对应一个压缩目录源数据,记录该目录的描述信息。压缩包中所有目录源数据连续存储在整个归档包的最后,这样便于向包中追加新的文件。
结构说明如下:
Central directory file header
Offset
Bytes
Description[18]
译
0
4
Central directory file header signature =0x02014b50
核心目录文件header标识=(0x02014b50)
4
2
Version made by
压缩所用的pkware版本
6
2
Version needed to extract (minimum)
解压所需pkware的最低版本
8
2
General purpose bit flag
通用位标记
10
2
Compression method
压缩方法
12
2
File last modification time
文件最后修改时间
14
2
File last modification date
文件最后修改日期
16
4
CRC-32
CRC-32算法
20
4
Compressed size
压缩后大小
24
4
Uncompressed size
未压缩的大小
28
2
File name length (n)
文件名长度
30
2
Extra field length (m)
扩展域长度
32
2
File comment length (k)
文件注释长度
34
2
Disk number where file starts
文件开始位置的磁盘编号
36
2
Internal file attributes
内部文件属性
38
4
External file attributes
外部文件属性
42
4
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.
本地文件header的相对位移。
46
n
File name
目录文件名
46+n
m
Extra field
扩展域
46+n+m
k
File comment
文件注释内容
3、 目录结束标识结构
目录结束标识存在于整个归档包的结尾,用于标记压缩的目录数据的结束。
结构说明如下:
End of central directory record
Offset
Bytes
Description[18]
译
0
4
End of central directory signature =0x06054b50
核心目录结束标记(0x06054b50)
4
2
Number of this disk
当前磁盘编号
6
2
Disk where central directory starts
核心目录开始位置的磁盘编号
8
2
Number of central directory records on this disk
该磁盘上所记录的核心目录数量
10
2
Total number of central directory records
核心目录结构总数
12
4
Size of central directory (bytes)
核心目录的大小
16
4
Offset of start of central directory, relative to start of archive
核心目录开始位置相对于archive开始的位移
20
2
Comment length (n)
注释长度
22
n
Comment
注释内容
- zip文件格式说明
- zip文件格式
- ZIP文件格式
- zip文件格式
- Zip文件格式
- zip文件格式
- zip文件格式
- python与zip文件格式
- 【文档】Zip文件格式
- ZIP文件格式详解
- ZIP文件格式详解
- ZIP文件格式详解
- zip 文件格式说明书
- zip、rar文件格式
- zip文件格式分析
- zip文件格式解析
- ZIP文件格式分析
- ZIP文件格式组成
- Monit 简单实践
- 服务器端的相对地址与绝对地址
- hdu 1124 Factorial
- 2015 ACMICPC Asia Regional Changchun Online
- xcode Unable to boot device because it cannot be located on disk解决方法
- zip文件格式说明
- HDU 5433 Xiao Ming climbing
- 用U盘制作启动盘后空间变小的恢复方法
- 第六章 :使用Prototype Cell 自定义表视图
- IO流
- Install Kaldi in Lubuntu 14.04
- spring3(1)
- 算法入门-第一天-字符串处理
- spring3(2)