3 releases

0.1.2 Dec 27, 2022
0.1.1 Jun 22, 2017
0.1.0 Jun 22, 2017

#48 in macOS and iOS APIs

Download history 357/week @ 2024-07-23 439/week @ 2024-07-30 416/week @ 2024-08-06 411/week @ 2024-08-13 353/week @ 2024-08-20 336/week @ 2024-08-27 393/week @ 2024-09-03 299/week @ 2024-09-10 251/week @ 2024-09-17 356/week @ 2024-09-24 502/week @ 2024-10-01 475/week @ 2024-10-08 339/week @ 2024-10-15 267/week @ 2024-10-22 278/week @ 2024-10-29 316/week @ 2024-11-05

1,274 downloads per month
Used in 5 crates (3 directly)

MIT/Apache

14KB
222 lines

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.

Dependencies

~3.5MB
~61K SLoC