3 个版本
0.1.2 | 2022年12月27日 |
---|---|
0.1.1 | 2017年6月22日 |
0.1.0 | 2017年6月22日 |
#44 在 macOS和iOS API
1,550 每月下载量
在 5 个Crate中使用 (3个直接使用)
14KB
222 行
dmg
简单的 macOS 磁盘镜像附加/卸载。
示例
附加磁盘镜像直到释放
use dmg::Attach;
let info = Attach::new("Test.dmg").with().expect("could not attach");
println!("Mounted at {:?}", info.mount_point);
// Detched when 'info' dropped
如果您喜欢自己处理卸载,只需使用 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()
如果您知道设备节点或挂载点,您也可以这样卸载它
use dmg;
dmg::detach("/Volumes/Test", false).expect("could not detach"); // Do not force detach
更多示例请参阅 src/tests.rs
和 src/bin/demo.rs
测试
要创建 Test.dmg
运行
./create_dmg.sh
这将创建一个包含单个名为 SAMPLE
的文件的读/写 .dmg 文件。
hdiutil
不喜欢同时附加和卸载相同的文件,因此使用以下命令进行测试
cargo test -- --test-threads 1
许可证
以下两种许可证之一授权:
- Apache许可证第2版 (LICENSE-APACHE 或 https://apache.ac.cn/licenses/LICENSE-2.0)
- MIT许可证 (LICENSE-MIT 或 http://opensource.org/licenses/MIT)
任选其一。
依赖关系
~3.5MB
~62K SLoC