如何使用python的zipfile库检查zip文件是否拆分为多个档案? [英] How to check if zip file is split across multiple archives using python's zipfile lib?
问题描述
根据zip文件标准: http://www.pkware.com/documents/casestudies/APPNOTE.TXT 它还支持将zip文件拆分为多个文件:
According to the zip file standard: http://www.pkware.com/documents/casestudies/APPNOTE.TXT it also supports splitting a zip file across multiple files:
Spanned/Split archives created using PKZIP for Windows
(V2.50 or greater), PKZIP Command Line (V2.50 or greater),
or PKZIP Explorer will include a special spanning
signature as the first 4 bytes of the first segment of
the archive. This signature (0x08074b50) will be
followed immediately by the local header signature for
the first file in the archive.
A special spanning marker may also appear in spanned/split
archives if the spanning or splitting process starts but
only requires one segment. In this case the 0x08074b50
signature will be replaced with the temporary spanning
marker signature of 0x30304b50. Split archives can
only be uncompressed by other versions of PKZIP that
know how to create a split archive.
The signature value 0x08074b50 is also used by some
ZIP implementations as a marker for the Data Descriptor
record. Conflict in this alternate assignment can be
avoided by ensuring the position of the signature
within the ZIP file to determine the use for which it
is intended.
有什么主意如何检查该签名或以其他方式检查zip是否拆分为多个文件?
Any idea how to check that signature or other way to check if a zip is split across multiple files?
推荐答案
他们在标准中讨论的特定签名,即PK\007\008
根本没有由zipfile处理,这可以通过在库中grepping看到.来源(我在Python 3.2中得到了相同的结果):
The particular signature that they are talking about in the standard, i.e. PK\007\008
is not handled by zipfile at all, as can be seen by grepping over the library source (I got the same result with Python 3.2):
# grep PK /usr/lib/python2.7/zipfile.py
stringEndArchive = "PK\005\006"
stringCentralDir = "PK\001\002"
stringFileHeader = "PK\003\004"
stringEndArchive64Locator = "PK\x06\x07"
stringEndArchive64 = "PK\x06\x06"
因此,我怀疑您是否可以为此目的使用该库.还可以尝试通过扩展库来自己找到该签名.
So I doubt that you can use the library for that purpose. Might as well try to find that signature yourself by extending the library.
这篇关于如何使用python的zipfile库检查zip文件是否拆分为多个档案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!