(MACOSX)-了解是否已从DMG安装了已安装的设备 [英] (MACOSX) - Knowing whether a mounted device was mounted from a DMG
本文介绍了(MACOSX)-了解是否已从DMG安装了已安装的设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用DiskArbitration或FSGetVolumeInfo/GetVolumeParms找不到该信息...
Couldn't find that info using DiskArbitration or FSGetVolumeInfo/GetVolumeParms...
我知道hdiutil使用一个称为DiskImages框架的私有框架,但是我不想每次想要此信息时都运行一个外部实用程序……该API的位置在哪里?
I know that hdiutil uses a private framework called DiskImages framework, but I wouldn't want to run an external utility each time I want this info... wheres the API for this ?
推荐答案
2015年7月更新
此更新是由Stan James的您可以使用获取此信息. DiskArbitration 框架.要使用下面的示例,您必须链接并#import
它.
You can obtain this information using the DiskArbitration framework. To use the example below, you must link against and #import
it.
#import <DiskArbitration/DiskArbitration.h>
...
- (BOOL)isDMGVolumeAtURL:(NSURL *)url
{
BOOL isDMG = NO;
if (url.isFileURL) {
DASessionRef session = DASessionCreate(kCFAllocatorDefault);
if (session != nil) {
DADiskRef disk = DADiskCreateFromVolumePath(kCFAllocatorDefault, session, (__bridge CFURLRef)url);
if (disk != nil) {
NSDictionary * desc = CFBridgingRelease(DADiskCopyDescription(disk));
NSString * model = desc[(NSString *)kDADiskDescriptionDeviceModelKey];
isDMG = ([model isEqualToString:@"Disk Image"]);
CFRelease(disk);
}
CFRelease(session);
}
}
return isDMG;
}
用法:
BOOL isDMG = [someObject isDMGVolumeAtURL:[NSURL fileURLWithPath:@"/Volumes/Some Volume"]];
我希望这会有所帮助.
这篇关于(MACOSX)-了解是否已从DMG安装了已安装的设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文