A ZIP archive can be divided into segments. The format counts these as disks, from the days of floppies. A member’s disk number says where it starts, and offsets count within a segment.
Spanned and split
| Spanned | Split | |
|---|---|---|
| Where the parts are | On removable media, typically floppy disks | On non-removable locations, as ordinary files |
| Names | All pieces have the same name | See naming |
| How order is known | DOS volume labels, PKBACK#001 and up | By the file names |
The two use the same layout inside.
Markers
A spanned or split archive starts with a four-byte marker before its first local header.
| Bytes | Value | Meaning |
|---|---|---|
50 4B 07 08 | 0x08074B50 | The first 4 bytes of the first segment of a spanned or split archive, followed by the first local header. |
50 4B 30 30 | 0x30304B50 | Temporary marker, PK00: splitting or spanning was started, but only one segment was needed. APPNOTE says only versions that can create split archives can extract it. |
The value 0x08074B50 is also the optional signature of a
data descriptor. APPNOTE says its
position in the file decides which it is.
Disk numbers
The first segment is disk 0. Each of these fields carries a disk number or a per-disk count. In a single-file archive all the numbers are 0.
| Record | Field | Meaning |
|---|---|---|
| Central header | Disk number | The disk the member starts on. |
| End record | Disk number | The disk the end record is on. |
| End record | Directory disk | The disk the central directory starts on. |
| End record | Entries on this disk | Central directory entries on this disk. Zero when the directory is encrypted. |
| ZIP64 end record | Disk number, directory disk, entries on this disk | The same, with wider fields. |
| ZIP64 locator | ZIP64 end disk, total disks | The disk holding the ZIP64 end record, and the number of disks. |
Offsets count from the start of the named disk, so an offset in the central directory is measured from the start of the segment holding that local header, and the directory’s offset from the start of the segment it starts on.
The end record and the ZIP64 locator must be on the same disk.
Segment rules and limits
- No header is split across segments. If the space left is too small, the segment ends there and the header starts the next one.
- The central directory may cross segment boundaries, but a single record is not split.
- Segments should all be the same size except the last.
| Limit | Value |
|---|---|
| Minimum segment size | 64 KiB |
| Maximum segment size (ZIP) | 4,294,967,295 bytes |
| Maximum segment size (PKSFX) | 2,147,483,647 bytes |
| Maximum number of segments | 4,294,967,294 |
A split self-extracting archive’s first segment must be named .exe and be
large enough to hold the whole executable.
File naming
A split archive’s segments are named name.z01, name.z02 and
so on, up to name.z(n−1), and the last segment is name.zip. So
the last segment, which holds the end record, has the usual extension.
Reading a split archive
- Open the file with the highest number, usually the
.zip, and find the end record. - Read the ZIP64 records if there are any. The number of disks is the end record’s disk number plus one, or the locator’s total.
- Open the disk the central directory starts on and read the directory, moving to the next disk as needed.
- For each member, open the disk named in its header and read at its offset. Data can continue onto the following disk.
Disk numbers from some single-file archives are wrong, but the local header is still where the offset says. The explorer treats a member whose local header is found at the stated offset, with the same name, as present even if its disk number says otherwise. It works on a single file, so it does not read other segments.