Unix compress (.Z)

LZW compression from the original Unix compress utility.

Overview

A .Z file begins with 1F 9D and a flags byte (maximum code width 9-16 bits, block mode bit). Codes are packed LSB first in groups, with width increases and an optional clear code in block mode. There is no checksum.

Where it is used

  • Old Unix archives (.tar.Z) and legacy software.

History

  • Written for Unix in 1984 (Spencer Thomas, Joe Orost and others); LZW patent issues led to gzip.

Status today

  • Obsolete; encountered in old archives.

Structures read by the implementation

Offsets are in bytes from the start of the buffer named in each heading. Field names are taken from the implementation and are not an official specification. Fixed-width integers are shown as u/i (unsigned/signed) followed by bit width and byte order.

Stop.Carve buffer stack ยท UnixCompressCarver.cs

OffsetSizeTypeFieldNotes
0x01bytesโ€“
0x01u8โ€“

Constants

General UnixCompressCarver

NameValueTypeNotes
TableSize1 << 16int
ClearCode256int
SectorSize512int

General LzwBits

NameValueTypeNotes
ZeroRunEnd64 * 1024int

Implementation limits reader

ClassNameValueNotes
UnixCompressCarverMaxTarPadding64L * 1024 * 1024
UnixCompressCarverMinPlainOutput512
LzwBitsChunkSize256 * 1024

Stop enum

NameValue
EndOfData(next)
ZeroSector(next)
BadCode(next)
TarEnd(next)
Unreadable(next)
Limit(next)
Structures and constants were extracted from: Carving/Plugins/Compressed/UnixCompressCarver.cs, Modules/FileSystems/UnixCompressArchiveModule.cs. Prose sections are a summary from public sources; verify details before relying on them.