Skip to main content

Module macbinary

Module macbinary 

Source
Expand description

MacBinary I / II / III — the canonical full-fidelity parser for the family.

MacBinary is a transport wrapper: it serializes exactly one Mac file’s data fork + resource fork + Finder metadata into a single flat stream. It is not a multi-file archive, so it joins the macarchive family as a single-entry StuffItArchive (see super::extract::open_bytes).

This module replaces the full-fidelity parser that used to live buried in the put-macbinary CLI verb. The lean resource_fork::parse_macbinary remains a separate, deliberately conservative host-sidecar import detector (it returns an ImportedResourceFork and only accepts CRC-validated II/III with a non-empty resource fork). The two have distinct roles; this one is the format reader.

Format reference: docs/native_mac_archives.md §2 (embedded spec).

§Two entry points

  • is_macbinary — the confidence-scored §2.4 detection heuristic, used by the content classifier. Strict on purpose: MacBinary I has no magic and lazy II writers zero the CRC, so a false positive would hijack an unrelated .bin.
  • parse — lenient structural parse for a buffer already believed to be MacBinary (e.g. a user-supplied put-macbinary input). Does not require a valid CRC, and accepts an empty resource fork (data-fork-only Mac files — a wrapped disk image, a text file — are legitimate MacBinary; the old resource_fork parser wrongly rejected them).

Structs§

MacBinaryFile
One Mac file recovered from a MacBinary stream: both forks plus the full Finder metadata the header carries.

Enums§

MacBinaryVersion
Which MacBinary revision a stream identifies as.

Functions§

is_macbinary
Classify bytes as MacBinary using the confidence-scored §2.4 heuristic. Returns the identified version, or None.
parse
Parse a buffer believed to be MacBinary into a MacBinaryFile. Lenient: no CRC enforcement (some legacy II archives carry garbage there) and an empty resource fork is accepted. Use is_macbinary first for content-driven detection.