首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用python的zipfile lib检查zip文件是否跨多个归档文件拆分?

如何使用python的zipfile lib检查zip文件是否跨多个归档文件拆分?
EN

Stack Overflow用户
提问于 2012-08-20 22:09:05
回答 1查看 1.9K关注 0票数 2

根据压缩文件标准:http://www.pkware.com/documents/casestudies/APPNOTE.TXT,它还支持将一个压缩文件拆分成多个文件:

代码语言:javascript
复制
      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是否被分割到多个文件中吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-08-20 22:27:41

他们在标准中讨论的特定签名,即PK\007\008根本不是由zipfile处理的,这可以从对库源代码的理解中看出(我在Python3.2中得到了同样的结果):

代码语言:javascript
复制
# 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"

所以我怀疑你是否可以使用这个库来达到这个目的。不妨尝试通过扩展库来自己找到那个签名。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12039237

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档