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
Probing a file
use macbinary_rs::{MacBinary,Error};
match macbinary_rs::probe_path("./sample-file.sit") {
Ok(MacBinary::None(file)) => {}
Ok(MacBinary::I(file)) => {}
Ok(MacBinary::II(file)) => {}
Ok(MacBinary::III(file)) => {}
Err(e) => eprintln!("Could not determine format of file: {:?}", e),
}
Opening a file
match macbinary_rs::open("./sample-file.sit") {
Ok(file) => {
println!("File: {} (encoding {})", file.file_name(), file.encoding());
println!("Type: {}/{}", file.creator_code(), file.type_code());
let mut reader = file.read(Fork::Data)?;
...
},
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.