Skip to main content

Module detect

Module detect 

Source
Expand description

Magic-sniff classifier for Mac archive bytes. Returns a single MacArchiveKind regardless of filename extension, so the GUI workflows in OPEN-WORK §6.1 can trigger off the actual file content rather than a possibly-misleading name.

Detection order:

  1. BinHex 4.0 (textual banner). If it decodes, re-sniff the inner data fork: a SIT/SIT5 payload yields BinHexOverSit, a SEA payload yields BinHexOverSea, anything else yields BinHexSingleFile (one Mac file’s worth of forks).
  2. Standalone classic StuffIt SIT!.
  3. Standalone StuffIt 5.
  4. Standalone SEA (Mac app data fork with a SIT! signature inside).

Anything else: None. The caller treats it as opaque bytes.

Enums§

MacArchiveKind
What kind of Mac archive a byte buffer is, if any.
MountableImageKind
A disk-image payload an archive’s single entry can resolve to. Returned by detect_mountable_image — the Workflow A and D.2 auto-unwrap hint uses this to surface “Mount in new Inspect tab” when the user picks an archive whose contents are themselves a disk image.

Functions§

detect_mac_archive
Classify bytes as a Mac archive if possible. Filename extension is irrelevant — detection runs purely on content magic. Returns None for anything that doesn’t match a known archive shape.
detect_mountable_image
Sniff a decompressed payload for “is this a disk image the Inspect tab can mount and partition-walk?” Tries DiskCopy 4.2 first (header at offset 0 plus size match), then raw HFS / HFS+ (MDB signature at byte 1024 — the BasiliskII HFV layout and the Apple_HFS partition layout share this offset).