Expand description
Compact Pro (.cpt) archive reader — Bill Goodman’s Compactor / Compact
Pro format, common for vintage Mac software and frequently distributed as a
BinHex-wrapped self-extracting archive (.sea.hqx).
Two-stage compression: a byte-level RLE layer, optionally fed by an LZH
(LZSS + canonical Huffman) layer. Each file carries a data and/or resource
fork plus Finder info, mapping cleanly onto the shared StuffItEntry /
StuffItArchive plumbing the rest of macarchive already uses, so the
directory tree and all four output formats in extract come for free.
Ported from XADMaster’s XADCompactProParser.m,
XADCompactProRLEHandle.m, and XADCompactProLZHHandle.m (which build on
XADLZSSHandle, XADPrefixCode, and CSInputBuffer, all under
~/repos/XADMaster). The block-padding quirk in the LZH layer and the
RLE escape sequence are faithful reproductions of that reference.
Functions§
- decompress_
fork - Decompress one Compact Pro fork (RLE, optionally LZH-fed). The CRC is not
checked here — Compact Pro stores one checksum per file covering the
resource fork followed by the data fork, so the caller verifies it once
both forks are in hand via
verify_entry_crc. - is_
compactpro - True iff
bytesis a Compact Pro archive. Mirrors XADMaster’s recognizer: the leading0x01marker is far too weak on its own, so we walk the index at the end of the file and confirm the stored CRC-32 over the directory. - parse
- Parse a Compact Pro archive’s directory into the shared entry tree. Fork
data offsets are absolute within
bytes, exactly like the StuffIt parsers. - verify_
entry_ crc - Verify a Compact Pro file’s CRC-32. The stored checksum covers the decompressed resource fork immediately followed by the decompressed data fork (either may be empty), as a single reflected CRC-32 with no final complement. This is the only integrity check for the format, so it runs for every entry — single-fork, dual-fork, and empty alike.