Expand description
Classic StuffIt (.sit) + StuffIt self-extracting (.sea) reader.
Container layout (reverse-engineered; see XADMaster XADStuffItParser.m,
mirrored in docs/native_mac_archives.md):
Archive header (22 bytes):
[0..4] "SIT!" magic
[4..6] number of entries (u16 BE) (informational; we walk to EOF)
[6..10] total archive length (u32 BE)
[10..14] "rLau" secondary signature
[14..22] version + reserved + header CRC
Per-entry header (112 bytes):
[0] resource-fork compression method
[1] data-fork compression method
[2] filename length (<= 31)
[3..34] filename (Mac Roman)
[66..70] file type [70..74] creator
[74..76] Finder flags
[76..80] creation date [80..84] modification date (Mac 1904 epoch)
[84..88] resource fork uncompressed length
[88..92] data fork uncompressed length
[92..96] resource fork compressed length
[96..100] data fork compressed length
[100..102] resource CRC [102..104] data CRC (CRC-16/ARC)
[110..112] header CRC (CRC-16/ARC over [0..110])
Then: <compressed resource fork><compressed data fork>A method byte’s high bit (0x80) marks an encrypted fork; 0x20/0x21
(after masking the encryption + folder-contains-encrypted bits) mark the
start/end of a folder. The low nibble is the compression method.
Structs§
- Fork
Info - One fork (data or resource) of a StuffIt or Compact Pro entry.
- SitDamage
- Bytes between two entries that no header accounts for, skipped by the entry walk (#101).
See
docs/native_mac_archives.mdsection 6a. - SitTruncation
- An archive whose header declares a longer stream than is present.
- Stuff
ItArchive - A parsed StuffIt archive (entries in archive order; directory structure is
reflected in each entry’s
path). - Stuff
ItEntry - One file or folder in a StuffIt archive.
- Stuff
ItInput - A single file to place into a StuffIt archive.
Enums§
- Fork
Codec - Which decompressor a
ForkInfoneeds. StuffIt and Compact Pro share the same entry/fork plumbing (the directory tree inStuffItEntryand every output format inextract) but use entirely different fork codecs and checksums, so the codec tag picks the right decompressor at extract time. - Stuff
ItInput Node - A node in a StuffIt input tree — either a file or a folder containing
further nodes. Used by
build_archive_treeto emit nested directory structures via the START_FOLDER (0x20) / END_FOLDER (0x21) marker entries that classic StuffIt uses for hierarchy. - Write
Method - Compression to use when writing a fork.
Functions§
- build_
archive - Build a classic StuffIt (
.sit) archive from a flat list of files. - build_
archive_ tree - Build a classic StuffIt (
.sit) archive from a node tree, emitting START_FOLDER (0x20) / END_FOLDER (0x21) marker entries for nested directories. Children of aFoldernode appear between its start and end markers; the round-trip throughparsereconstructs the directory path in each entry’spathfield. - decompress_
fork - Decompress one fork from the archive bytes, verifying its CRC.
- find_
sea_ archive - Locate the StuffIt archive inside a
.sea(self-extracting archive). A StuffIt SEA is a Mac application whose payload is a plain.sitstream; we scan for theSIT!…rLausignature. Returns the offset of the archive. - is_
stuffit - Detect whether
databegins with a classic StuffIt archive. - parse
- Parse a StuffIt archive (or the
.sitstream embedded in a.sea).