Skip to main content

Module stuffit

Module stuffit 

Source
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§

ForkInfo
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.md section 6a.
SitTruncation
An archive whose header declares a longer stream than is present.
StuffItArchive
A parsed StuffIt archive (entries in archive order; directory structure is reflected in each entry’s path).
StuffItEntry
One file or folder in a StuffIt archive.
StuffItInput
A single file to place into a StuffIt archive.

Enums§

ForkCodec
Which decompressor a ForkInfo needs. StuffIt and Compact Pro share the same entry/fork plumbing (the directory tree in StuffItEntry and every output format in extract) but use entirely different fork codecs and checksums, so the codec tag picks the right decompressor at extract time.
StuffItInputNode
A node in a StuffIt input tree — either a file or a folder containing further nodes. Used by build_archive_tree to emit nested directory structures via the START_FOLDER (0x20) / END_FOLDER (0x21) marker entries that classic StuffIt uses for hierarchy.
WriteMethod
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 a Folder node appear between its start and end markers; the round-trip through parse reconstructs the directory path in each entry’s path field.
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 .sit stream; we scan for the SIT!…rLau signature. Returns the offset of the archive.
is_stuffit
Detect whether data begins with a classic StuffIt archive.
parse
Parse a StuffIt archive (or the .sit stream embedded in a .sea).