(MACOSX) - knowing if a mounted device is mounted from DMG
1 answer
July 2015 Update
This update was suggested by Stan James in a new question .
You can get this information using DiskArbitration . To use the example below, you have to link it and #import
.
#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;
}
Using:
BOOL isDMG = [someObject isDMGVolumeAtURL:[NSURL fileURLWithPath:@"/Volumes/Some Volume"]];
Hope this helps.
+1
source to share