创建提取跨平台的 ZIP 文件

创建提取跨平台的 ZIP 文件

我需要跨平台分发一个大型文件(6GB+)。出于实际原因,我想将其压缩到 2GB+。我最初使用 Mac OS 10.11 通过 Archive Utility 创建了 zip 文件。它在我的 Linux 上解压得很好,但在 Windows 10 上解压却不行(使用系统实用程序)。在 Linux 上压缩原始文件时,我可以在 Windows 10 上解压,但在 Mac OS X 上解压却失败。当我尝试使用 Mac OS Xunzip上的命令行程序解压时,出现以下错误:

Archive:  UbuntuLTS.vdi.zip
warning [UbuntuLTS.vdi.zip]:  76 extra bytes at beginning or within zipfile
  (attempting to process anyway)
error [UbuntuLTS.vdi.zip]:  reported length of central directory is
  -76 bytes too long (Atari STZip zipfile?  J.H.Holm ZIPSPLIT 1.1
  zipfile?).  Compensating...
   skipping: UbuntuLTS.vdi           need PK compat. v4.5 (can do v2.1)

note:  didn't find end-of-central-dir signature at end of central dir.
  (please check that you have transferred or created the zipfile in the
  appropriate BINARY mode and that you have compiled UnZip properly)

Mac 运行的是zip3.0(2008 年 7 月 5 日)和unzip5.52(2005 年 2 月 28 日)。Linux 运行的是zip3.0(2008 年 7 月 5 日)和unzip6.00(2009 年 4 月 20 日)。不知道 Windows 使用的是哪种版本。我需要 zip 文件能够在 Mac OS X、Linux 和 Windows(7、8、8.1 和 10)上正确解压。我不想告诉人们下载第三方程序。我还想了解到底发生了什么。我从来没有遇到过 zip 格式在不同平台上不兼容的问题。

对于您提出的任何解决方案,开箱即用的后 Windows Vista 是必须的,因为这些将是最大的目标群体。我知道要求它在“Linux”上运行有点不明确。

答案1

unzip6.0 版之前的版本不支持将大于 4 Gb 的 zip 文件解压为未压缩文件(或 2 Gb,http://www.info-zip.org/FAQ.html#limits)例如https://superuser.com/a/394915/504096https://unix.stackexchange.com/a/220054

不幸的是,MacOS 提供的标准版本unzip不是 6.0 而是 5.X。MacOS 的 6.0 版本可以在这里获取:http://www.macupdate.com/app/mac/35967/unzip。本文介绍如何安装版本 6:https://apple.stackexchange.com/q/149080

此外,unzip需要使用选项LARGE_FILE_SUPPORT和进行编译ZIP64_SUPPORT,以便能够处理 2 Gb / 4 Gb 以上的文件。通常情况下,情况应该如此。要确定是否unzip进行了相应的编译,请键入unzip -version。输出中应该有类似以下内容:

UnZip 6.00 of 20 April 2009 ...
...
UnZip special compilation options:
...
LARGE_FILE_SUPPORT (large files over 2 GiB supported)
ZIP64_SUPPORT (archives using Zip64 for large files supported)
....

的替代方法unzip是使用7zip非官方提供的非 Windows 操作系统 - 例如 MacOS(名为7zX)。

相关内容