Zip64 Format: Crossing the Limits of File Sizes and Number of Files and Segments
Introduction
The Zip64 format is an extension to the standard zip format that practically removes
limits in sizes and item numbers within a zip archive.
The ZipArchive Library automatically uses the Zip64 extensions when the regular
zip archive limits are exceeded. The ZipArchive
Library will not otherwise include the extensions in the archive, even if the extensions
are enabled (see the paragraph below). The extensions will be removed from the archive
when due to some modifications they are not needed anymore. The library also automatically
detects an archive in the Zip64 format.
Enabling Zip64 Extensions in the ZipArchive Library
To use the Zip64 extensions, you need to make sure that
_ZIP64
is defined in the file
_features.h. It is disabled by
default. Rebuild the ZipArchive Library and your application, if you modify this
definition. You should keep the extensions disabled, if you don't use them, otherwise
the library will use
64-bit types and perform more processing,
which may slow down your application.
Limits Compared: the Standard Format Versus Zip64 Format
The maximum values allowed in each format are summarized below:
|
Number of Files Inside an Archive |
65,535 |
2^64 - 1 |
|
Size of a File Inside an Archive [bytes] |
4,294,967,295* |
2^64 - 1 |
|
Size of an Archive [bytes] |
4,294,967,295* |
2^64 - 1 |
|
Number of Segments in a Segmented Archive |
999 (spanning)
65,535 (splitting) |
4,294,967,295 - 1 |
|
Central Directory Size [bytes] |
4,294,967,295* |
2^64 - 1 |
* This is limited to 2,147,483,647 on STL implementations without
Zip64 enabled and on Microsoft Visual Studio 6.0 (MFC). See
the next paragraph, how to work around
these
limitations. This limit also exists under CodeGear C++Builder and Borland C++ but without ready workarounds.
Platforms Limitations in Processing Large Data
When processing files and collections, the ZipArchive Library relies on external
libraries, such as STL and MFC. If you wish to use Zip64 extensions, you need to
make sure that the implementation of STL or MFC that you use, supports large files
and large collections.
Large Files
Most of the implementations support large files (> 4GB) processing. The exceptions
are listed below:
- STL without Zip64 enabled is limited to handling files of maximum 2GB size
due to the use of signed types in file handling functions. To remove this limit
enable Zip64 functionality and the library
will use large types (Zip64 extensions will be used only when needed).
- Microsoft Visual Studio 6.0 (MFC) does not support large files. The workaround
for this is to use the STL implementation of the
CZipFile
class instead of MFC implementation under this platform. This is handled by the
ZipArchive Library by automatically defining ZIP_FILE_USES_STL
in the _features.h file, when Zip64 is enabled under this
platform. Note that
the CZipFile class does not derive from CFile
in this case.
- CodeGear C++Builder & Borland C++ (STL & MFC) - Zip64 functionality is not supported under
this platform. The workaround for this case would be to use a custom STL implementation.
Large Collections
The maximum number of items a collection can hold, limits the maximum number of
files in an archive that the ZipArchive Library can process. This limit can be determined
by examining the
ZIP_ARRAY_SIZE_TYPE definition. This
is defined as:
size_t in the STL version
INT_PTR in the MFC version
The MFC version also depends on
size_t type when sorting.
These types are usually defined as unsigned
32-bit integer
types. You may need to use a
64-bit compiler for a larger
collections support.