Skip to main content

Crate macbinary

Crate macbinary 

Source
Expand description

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

Modules§

structs
On-disk structures

Structs§

Config
MacBinary
Wrapper for transparently reading MacBinary encoded files
Reader

Enums§

ResourceForkDetectionStrategy
Strategy to detect resource fork on the disk
Version

Functions§

open_file
Create a MacBinary by opening the given path
probe
Determine the MacBinary version used by the reader
probe_file
Determine the MacBinary version used by the given file

Type Aliases§

Error
Fork