ZIP

From Just Solve the File Format Problem
(Difference between revisions)
Jump to: navigation, search
(Added Coldwind)
(Rearranged article)
Line 12: Line 12:
 
|released=1989
 
|released=1989
 
}}
 
}}
'''ZIP''' is one of the most popular file compression formats. It was created in 1989 as the native format of the PKZIP program, which was introduced by Phil Katz (with co-creator Gary Conway) in the wake of a lawsuit (which he lost) against him by the makers of the then-popular [[ARC (compression format)|ARC]] program (and file format) for copyright and trademark infringement in an earlier program [[PKARC]] which had been file-compatible with ARC.  This resulted in Katz creating a new file format, which rapidly overtook ARC in popularity (to a large extent because of BBS sysops, then the primary users of such compression, resenting the lawsuit). Many programs have been released for a variety of operating systems to compress and decompress ZIP files, and native support for the format is built into several popular operating systems.
+
'''ZIP''' is one of the most popular file compression/archiving formats.
 
+
ZIP implementations vary in their support for features in the specification from PKWARE<ref>http://www.pkware.com/documents/casestudies/APPNOTE.TXT</ref>, particularly features added since version 2 (1993), some of which are protected by patents and require licensing.  Many implementations limit the use of compression to the [[DEFLATE]] algorithm, introduced with version 2. Extensions incorporated into the specification that have been widely adopted are: long filenames; large files (using a technique known as ZIP64); and filenames in [[UTF-8]].  In 2011 work began on an interoperable subset of the latest APPNOTE.TXT with the intention of publication as ISO/IEC 21320-1, Document Container File -- Part 1: Core.  As of November 2012, a discussion draft is available<ref>http://kikaku.itscj.ipsj.or.jp/sc34/open/1855.pdf</ref>.  Designed to promote interoperable implementations, the draft ISO/IEC 21320-1 prohibits compression other than using [[DEFLATE]], segmentation or multiple volumes, and features that are subject to patents.
+
 
+
While .zip is the usual file extension, ZIP-formatted files can be found with many other extensions since a number of other file formats use ZIP compression but store their files in application-specific extensions. See [[:Category:ZIP based file formats]] for a list of such formats.
+
 
+
== See also ==
+
* [[PKLITE]]
+
* [[Self-extracting ZIP]]
+
* [[Zipx]]
+
  
 
== Disambiguation ==
 
== Disambiguation ==
 
The term "ZIP compression" is sometimes misleadingly used to mean [[DEFLATE]] (which is by far the most common compression scheme used in ZIP files). In such cases, the compressed data format could turn out to be raw [[DEFLATE]], or [[zlib]], or [[gzip]].
 
The term "ZIP compression" is sometimes misleadingly used to mean [[DEFLATE]] (which is by far the most common compression scheme used in ZIP files). In such cases, the compressed data format could turn out to be raw [[DEFLATE]], or [[zlib]], or [[gzip]].
  
== Identification ==
+
== Discussion ==
The byte sequence <code>'P' 'K' 0x05 0x06</code> (the "end of central directory signature") appears somewhere in the file, usually beginning exactly 22 bytes from the end of the file. However, it will appear earlier if the file contains a "ZIP file comment" (common in the BBS era, but rare today), or for various other reasons. There seems to be no theoretical limit to how far back you may have to search for the signature, but some software limits it to around 64KB, which is the maximum length of a comment.
+
It was created in 1989 as the native format of the PKZIP program, which was introduced by Phil Katz (with co-creator Gary Conway) in the wake of a lawsuit (which he lost) against him by the makers of the then-popular [[ARC (compression format)|ARC]] program (and file format) for copyright and trademark infringement in an earlier program [[PKARC]] which had been file-compatible with ARC.  This resulted in Katz creating a new file format, which rapidly overtook ARC in popularity (to a large extent because of BBS sysops, then the primary users of such compression, resenting the lawsuit). Many programs have been released for a variety of operating systems to compress and decompress ZIP files, and native support for the format is built into several popular operating systems.
  
Most ZIP files (but not [[self-extracting ZIP]] files) happen to begin with <code>'P' 'K' 0x03 0x04</code>. This is not a global file signature, but is the signature that appears once for every compressed file inside the ZIP file. Some ZIP-based formats are designed such that they necessarily begin in this way. But in general, it is even legal for a ZIP file to contain zero files, and such a ZIP file would not contain this signature at all.
+
ZIP implementations vary in their support for features in the specification from PKWARE<ref>http://www.pkware.com/documents/casestudies/APPNOTE.TXT</ref>, particularly features added since version 2 (1993), some of which are protected by patents and require licensing.  Many implementations limit the use of compression to the [[DEFLATE]] algorithm, introduced with version 2. Extensions incorporated into the specification that have been widely adopted are: long filenames; large files (using a technique known as ZIP64); and filenames in [[UTF-8]].  In 2011 work began on an interoperable subset of the latest APPNOTE.TXT with the intention of publication as ISO/IEC 21320-1, Document Container File -- Part 1: Core.  As of November 2012, a discussion draft is available<ref>http://kikaku.itscj.ipsj.or.jp/sc34/open/1855.pdf</ref>. Designed to promote interoperable implementations, the draft ISO/IEC 21320-1 prohibits compression other than using [[DEFLATE]], segmentation or multiple volumes, and features that are subject to patents.
  
That Phil Katz guy has thus managed to get his initials at the start of a large number of files on many millions of computers and devices, given how many file formats are based on ZIP (even if they use different extensions). He died in 2000, but this memorial to him will live on indefinitely.
+
While .zip is the usual file extension, ZIP-formatted files can be found with many other extensions since a number of other file formats use ZIP compression but store their files in application-specific extensions. See [[:Category:ZIP based file formats]] for a list of such formats.
  
== Compression ==
+
== Format details ==
 +
=== Compression ===
 
Each file in a ZIP file is compressed using one of a number of compression algorithms. Only compression types 0 (uncompressed) and 8 (DEFLATE) are likely to be seen in modern portable ZIP files. In old ZIP files, types 1 (Shrink) and 6 (Implode) are common.
 
Each file in a ZIP file is compressed using one of a number of compression algorithms. Only compression types 0 (uncompressed) and 8 (DEFLATE) are likely to be seen in modern portable ZIP files. In old ZIP files, types 1 (Shrink) and 6 (Implode) are common.
  
Line 82: Line 74:
 
|}
 
|}
  
== Extensible data fields ==
+
=== Extensible data fields ===
 
Each member file of a ZIP file may have one or more ''extensible data fields'' (or ''extra fields''), containing arbitrary data. Each field is tagged with a 16-bit identifier. Extra fields are normally used for platform-specific or filesystem-specific metadata, or to work around limitations of the original ZIP format. They are not normally used for application-specific data.
 
Each member file of a ZIP file may have one or more ''extensible data fields'' (or ''extra fields''), containing arbitrary data. Each field is tagged with a 16-bit identifier. Extra fields are normally used for platform-specific or filesystem-specific metadata, or to work around limitations of the original ZIP format. They are not normally used for application-specific data.
  
 
Most of the extra fields in use are documented in the ZIP "APPNOTE" specification, or by the Info-ZIP software (e.g. the proginfo/extrafld.txt file in the Zip program's source distribution).
 
Most of the extra fields in use are documented in the ZIP "APPNOTE" specification, or by the Info-ZIP software (e.g. the proginfo/extrafld.txt file in the Zip program's source distribution).
  
=== Known extensible data fields ===
+
Known extensible data fields:
 
{| class="wikitable"
 
{| class="wikitable"
 
!ID !! Owner !! Description !! Reference (identification) !! Reference (details)
 
!ID !! Owner !! Description !! Reference (identification) !! Reference (details)
Line 203: Line 195:
 
|0xfd4a || || SMS/QDOS || APPNOTE ||
 
|0xfd4a || || SMS/QDOS || APPNOTE ||
 
|}
 
|}
 +
 +
== Identification ==
 +
The byte sequence <code>'P' 'K' 0x05 0x06</code> (the "end of central directory signature") appears somewhere in the file, usually beginning exactly 22 bytes from the end of the file. However, it will appear earlier if the file contains a "ZIP file comment" (common in the BBS era, but rare today), or for various other reasons. There seems to be no theoretical limit to how far back you may have to search for the signature, but some software limits it to around 64KB, which is the maximum length of a comment.
 +
 +
Most ZIP files (but not [[self-extracting ZIP]] files) happen to begin with <code>'P' 'K' 0x03 0x04</code>. This is not a global file signature, but is the signature that appears once for every compressed file inside the ZIP file. Some ZIP-based formats are designed such that they necessarily begin in this way. But in general, it is even legal for a ZIP file to contain zero files, and such a ZIP file would not contain this signature at all.
 +
 +
That Phil Katz guy has thus managed to get his initials at the start of a large number of files on many millions of computers and devices, given how many file formats are based on ZIP (even if they use different extensions). He died in 2000, but this memorial to him will live on indefinitely.
 +
 +
== See also ==
 +
* [[PKLITE]]
 +
* [[Self-extracting ZIP]]
 +
* [[Zipx]]
  
 
== Specifications ==
 
== Specifications ==

Revision as of 15:04, 3 October 2023

Not to be confused with Zip disk, an unrelated disk cartridge unit.
File Format
Name ZIP
Ontology
Extension(s) .zip
MIME Type(s) application/zip
LoCFDD fdd000354, fdd000355, fdd000362, fdd000361
PRONOM x-fmt/263
UTI com.pkware.zip-archive
Wikidata ID Q136218
Kaitai Struct Spec zip.ksy
Released 1989

ZIP is one of the most popular file compression/archiving formats.

Contents

Disambiguation

The term "ZIP compression" is sometimes misleadingly used to mean DEFLATE (which is by far the most common compression scheme used in ZIP files). In such cases, the compressed data format could turn out to be raw DEFLATE, or zlib, or gzip.

Discussion

It was created in 1989 as the native format of the PKZIP program, which was introduced by Phil Katz (with co-creator Gary Conway) in the wake of a lawsuit (which he lost) against him by the makers of the then-popular ARC program (and file format) for copyright and trademark infringement in an earlier program PKARC which had been file-compatible with ARC. This resulted in Katz creating a new file format, which rapidly overtook ARC in popularity (to a large extent because of BBS sysops, then the primary users of such compression, resenting the lawsuit). Many programs have been released for a variety of operating systems to compress and decompress ZIP files, and native support for the format is built into several popular operating systems.

ZIP implementations vary in their support for features in the specification from PKWARE[1], particularly features added since version 2 (1993), some of which are protected by patents and require licensing. Many implementations limit the use of compression to the DEFLATE algorithm, introduced with version 2. Extensions incorporated into the specification that have been widely adopted are: long filenames; large files (using a technique known as ZIP64); and filenames in UTF-8. In 2011 work began on an interoperable subset of the latest APPNOTE.TXT with the intention of publication as ISO/IEC 21320-1, Document Container File -- Part 1: Core. As of November 2012, a discussion draft is available[2]. Designed to promote interoperable implementations, the draft ISO/IEC 21320-1 prohibits compression other than using DEFLATE, segmentation or multiple volumes, and features that are subject to patents.

While .zip is the usual file extension, ZIP-formatted files can be found with many other extensions since a number of other file formats use ZIP compression but store their files in application-specific extensions. See Category:ZIP based file formats for a list of such formats.

Format details

Compression

Each file in a ZIP file is compressed using one of a number of compression algorithms. Only compression types 0 (uncompressed) and 8 (DEFLATE) are likely to be seen in modern portable ZIP files. In old ZIP files, types 1 (Shrink) and 6 (Implode) are common.

Code Compression scheme Notes and references
0 Uncompressed
1 Shrink LZW. Used by PKZIP 0.x and 1.x.
2–5 Reduce LZ77 + prediction. Used by PKZIP v0.x. See also SCRNCH.
6 Implode LZ77 + Huffman. Used by PKZIP v1.x.
7 Tokenized Never used?
8 DEFLATE LZ77 + Huffman. Used by PKZIP v2.0+.
9 Deflate64, a.k.a. Enhanced Deflate Format version 2.1+.
10 PKWARE DCL Implode (old IBM TERSE) Format version 2.5+.
12 Bzip2 Format version 4.6+.
14 LZMA (EFS) Defined in ZIP specification v6.3+.
16 IBM z/OS CMPSC Defined in ZIP specification v6.3.5+.
18 IBM TERSE (new) Defined in ZIP specification v6.2.2+.
19 IBM LZ77 z Architecture (PFS) Defined in ZIP specification v6.3.5+.
93 Zstandard Defined in ZIP specification v6.3.8+.
94 MP3 Defined in ZIP specification v6.3.8+. Supported by WinZip 21+.
95 XZ Defined in ZIP specification v6.3.8+. Supported by WinZip 18+.
96 JPEG variant Defined in ZIP specification v6.3.5+.
97 WavPack Defined in ZIP specification v6.3.2+.
98 PPMd version I, Rev 1 Defined in ZIP specification v6.3+.
99 AES / AE-x encryption marker Defined in ZIP specification v6.3.5+.

Extensible data fields

Each member file of a ZIP file may have one or more extensible data fields (or extra fields), containing arbitrary data. Each field is tagged with a 16-bit identifier. Extra fields are normally used for platform-specific or filesystem-specific metadata, or to work around limitations of the original ZIP format. They are not normally used for application-specific data.

Most of the extra fields in use are documented in the ZIP "APPNOTE" specification, or by the Info-ZIP software (e.g. the proginfo/extrafld.txt file in the Zip program's source distribution).

Known extensible data fields:

ID Owner Description Reference (identification) Reference (details)
0x0001 PKWARE Zip64 extended information APPNOTE APPNOTE, Info-ZIP
0x0007 PKWARE AV Info APPNOTE
0x0008 PKWARE Reserved for extended language encoding data (PFS) APPNOTE
0x0009 PKWARE OS/2 APPNOTE APPNOTE, Info-ZIP
0x000a PKWARE NTFS APPNOTE APPNOTE, Info-ZIP
0x000c PKWARE OpenVMS APPNOTE APPNOTE, Info-ZIP
0x000d PKWARE UNIX APPNOTE APPNOTE, Info-ZIP
0x000e PKWARE Reserved for file stream and fork descriptors APPNOTE
0x000f PKWARE Patch Descriptor APPNOTE APPNOTE, Info-ZIP
0x0014 PKWARE PKCS#7 Store for X.509 Certificates APPNOTE APPNOTE, Info-ZIP
0x0015 PKWARE X.509 Certificate ID and Signature for individual file APPNOTE APPNOTE, Info-ZIP
0x0016 PKWARE X.509 Certificate ID for Central Directory APPNOTE APPNOTE, Info-ZIP
0x0017 PKWARE Strong Encryption Header APPNOTE APPNOTE
0x0018 PKWARE Record Management Controls APPNOTE APPNOTE
0x0019 PKWARE PKCS#7 Encryption Recipient Certificate List APPNOTE APPNOTE
0x0020 PKWARE Reserved for Timestamp APPNOTE
0x0021 PKWARE Policy Decryption Key APPNOTE APPNOTE
0x0022 PKWARE Smartcrypt Key Provider APPNOTE APPNOTE
0x0023 PKWARE Smartcrypt Policy Key Data APPNOTE APPNOTE
0x0065 PKWARE MVS / IBM S/390 (Z390) attributes - uncompressed APPNOTE APPNOTE
PKWARE OS/400 / AS/400 (I400) attributes - uncompressed APPNOTE APPNOTE
0x0066 PKWARE Reserved for IBM S/390 (Z390), AS/400 (I400) attributes - compressed APPNOTE
0x07c8 Macintosh (Info-ZIP Macintosh, old) APPNOTE Info-ZIP
0x2605 ZipIt Macintosh APPNOTE APPNOTE, Info-ZIP
0x2705 ZipIt Macintosh 1.3.5+ (w/o full filename) APPNOTE APPNOTE, Info-ZIP
0x2805 ZipIt Macintosh 1.3.5+ APPNOTE APPNOTE
0x334d "M3" Info-ZIP Macintosh APPNOTE Info-ZIP
0x4154 "TA" Tandem NSK Info-ZIP Info-ZIP
0x4341 "AC" Acorn/SparkFS APPNOTE Info-ZIP
0x4453 "SE" Windows NT security descriptor (binary ACL) APPNOTE Info-ZIP
0x4690 PKWARE POSZIP 4690 (reserved) APPNOTE
0x4704 VM/CMS APPNOTE Info-ZIP
0x470f MVS APPNOTE Info-ZIP
0x4854 "TH" Theos (old) Info-ZIP Info-ZIP
0x4b46 "FK" FWKCS MD5 APPNOTE APPNOTE, Info-ZIP
0x4c41 "AL" OS/2 access control list (text ACL) APPNOTE Info-ZIP
0x4d49 "IM" Info-ZIP OpenVMS APPNOTE Info-ZIP
0x4d63 "cM" Macintosh SmartZIP Info-ZIP Info-ZIP
0x4f4c "LO" Xceed original location APPNOTE
0x5350 "PS" (Observed in some Psion files.)
0x5356 "VS" AOS/VS (binary ACL) APPNOTE Info-ZIP
0x5455 "UT" Extended timestamp APPNOTE Info-ZIP
0x554e "NU" Xceed unicode APPNOTE
0x5855 "UX" Info-ZIP UNIX (original, also OS/2, NT, etc.) APPNOTE Info-ZIP
0x6375 "uc" Info-ZIP Unicode Comment APPNOTE APPNOTE, Info-ZIP
0x6542 "Be" BeOS (BeBox, PowerMac, etc.) APPNOTE Info-ZIP
0x6854 "Th" Theos Info-ZIP Info-ZIP
0x7075 "up" Info-ZIP Unicode Path APPNOTE APPNOTE, Info-ZIP
0x7441 "At" AtheOS Old Info-ZIP Old Info-ZIP (e.g. zip v2.32 [1])
0x756e "nu" ASi UNIX APPNOTE Info-ZIP
0x7855 "Ux" Info-ZIP Unix (previous new) APPNOTE Info-ZIP
0x7875 "ux" Info-ZIP Unix (new) Info-ZIP Info-ZIP
0xa11e Data Stream Alignment APPNOTE APPNOTE
0xa220 Microsoft Open Packaging Growth Hint APPNOTE APPNOTE
0xfb4a SMS/QDOS Info-ZIP Info-ZIP
0xfd4a SMS/QDOS APPNOTE

Identification

The byte sequence 'P' 'K' 0x05 0x06 (the "end of central directory signature") appears somewhere in the file, usually beginning exactly 22 bytes from the end of the file. However, it will appear earlier if the file contains a "ZIP file comment" (common in the BBS era, but rare today), or for various other reasons. There seems to be no theoretical limit to how far back you may have to search for the signature, but some software limits it to around 64KB, which is the maximum length of a comment.

Most ZIP files (but not self-extracting ZIP files) happen to begin with 'P' 'K' 0x03 0x04. This is not a global file signature, but is the signature that appears once for every compressed file inside the ZIP file. Some ZIP-based formats are designed such that they necessarily begin in this way. But in general, it is even legal for a ZIP file to contain zero files, and such a ZIP file would not contain this signature at all.

That Phil Katz guy has thus managed to get his initials at the start of a large number of files on many millions of computers and devices, given how many file formats are based on ZIP (even if they use different extensions). He died in 2000, but this memorial to him will live on indefinitely.

See also

Specifications

Metaformat files

Software

Sample files

Links

References

  1. http://www.pkware.com/documents/casestudies/APPNOTE.TXT
  2. http://kikaku.itscj.ipsj.or.jp/sc34/open/1855.pdf
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox