macbinary-rs

Crates.iomacbinary-rs
lib.rsmacbinary-rs
version0.2.0
created_at2026-01-25 10:31:35.848701+00
updated_at2026-01-25 17:13:41.838547+00
descriptionTransparent access to MacBinary-encoded files
homepage
repositoryhttps://codeberg.org/cyco/macbinary-rs.git
max_upload_size
id2068509
size48,976
(cyco)

documentation

README

Macbinary-rs

This crate aims to provide transparent access to macbinary files following the documentation at https://github.com/mietek/theunarchiver/wiki/MacBinarySpecs

Usage

The intended usage is as follows

Identifying MacBinary files

use macbinary::{MacBinary, Error, Version};

match macbinary::probe_file("./sample-file.sit") {
  Ok(Version::None) => {}
  Ok(Version::MacBinaryI) => {}
  Ok(Version::MacBinaryII) => {}
  Ok(Version::MacBinaryIII) => {}
  Err(e) => eprintln!("Could not determine format of file: {:?}", e),
}

Opening a file

use macbinary::Fork;

match macbinary::open_file("./sample-file.sit") {
  Ok(mut file) => {
    println!("File: {}", file.name());
    println!("Type: {}/{}", file.creator_code(), file.type_code());

   let mut reader = file.open_fork(Fork::Data).unwrap();
   // .. read data from reader
  },
  Err(e) => eprintln!("Could not open file {:?}", e)
}

If file is not a macbinary, it will return sensible defaults for all fields, provide a transparent reader for the data fork and an empty reader for the resource fork.

Limitations

At the moment the crate does not actually try to locate the resource fork if the opened file is not MacBinary encoded.

Checksum verification is not implemented.

Commit count: 0

cargo fmt