dmg

Crates.iodmg
lib.rsdmg
version0.1.2
sourcesrc
created_at2017-06-22 15:11:09.522039
updated_at2022-12-27 03:43:33.764784
descriptionSimple attaching/detaching of macOS disk images
homepagehttps://github.com/mgoszcz2/dmg
repositoryhttps://github.com/mgoszcz2/dmg
max_upload_size
id20173
size34,947
Maciej Goszczycki (maciej-irl)

documentation

https://docs.rs/dmg/

README

dmg

Simple attaching/detaching of macOS disk images.

Build Status crates.io Docs

Example

Attach a disk image until dropped:

use dmg::Attach;
let info = Attach::new("Test.dmg").with().expect("could not attach");
println!("Mounted at {:?}", info.mount_point);
// Detched when 'info' dropped

If you prefer to handle detaching yourself simply use attach():

use dmg::Attach;
let info = Attach::new("Test.dmg").attach().expect("could not attach");
println!("Device node {:?}", info.device);
info.detach().expect("could not detach"); // There is also .force_detach()

If you know the device node or mount point, you can detach it like this too:

use dmg;
dmg::detach("/Volumes/Test", false).expect("could not detach"); // Do not force detach

For more examples see src/tests.rs and src/bin/demo.rs

Testing

To create Test.dmg run:

./create_dmg.sh

This will create a read-write .dmg file containg a single file called SAMPLE.

hdiutil doesn not like attaching and detaching the same file concurrently, so test using:

cargo test -- --test-threads 1

License

Licensed under either of

at your option.

Commit count: 7

cargo fmt