在这个ZIP文件结构的上下文中有什么“磁盘”?

时间:2018-02-11 00:13:55

标签: file zip disk file-structure

我正在为自己制作一个迷你库来压缩和提取ZIP文件。到目前为止,我没有the documentation的任何重大问题,除了我没有得到ZIP文件中的“磁盘”以及如何计算磁盘的数量:

  

4.3.16中央目录记录结束:

end of central dir signature    4 bytes  (0x06054b50)

number of this disk             2 bytes   <= What does "disk" mean here?

number of the disk with the
start of the central directory  2 bytes   <= What does "disk" mean here?

total number of entries in the
central directory on this disk  2 bytes   <= What does "disk" mean here?

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   <= What does "disk" mean here?

.ZIP file comment length        2 bytes

.ZIP file comment       (variable size)

1 个答案:

答案 0 :(得分:4)

术语disk在分割和跨越ZIP文件的上下文中引用软盘(参见您提供的the documentation第8.0章;强调我的):

  

8.1.1跨越是分割ZIP文件的过程   多个可移动媒体。这种支持通常只有   为DOS格式的软盘提供。

如今,实现通常不再支持拆分和跨越(例如here(请参阅限制)或here(请参阅过程finish_zip())),因为软盘甚至是光盘已经消失时尚如果您没有支持拆分和跨越(首先),您可以按如下方式设置值:

number of this disk             2 bytes   <=  You only have one disk/file, so set it to 1.

number of the disk with the
start of the central directory  2 bytes   <=  You only have one disk/file, so set it to 1.

total number of entries in the
central directory on this disk  2 bytes   <=  Set it to the overall number of records.

offset of start of central
directory with respect to
the starting disk number        4 bytes   <=  Set this offset (in bytes) relative to
                                              the start of your archive.

如果要支持拆分或跨越,则每次开始写入新磁盘/文件时都必须增加磁盘数。重置每个新磁盘/文件的total number of entries in the central directory on this disk。计算相对于文件开头的偏移量。