summaryrefslogtreecommitdiffstats
path: root/macosx/HBDVDDetector.m
diff options
context:
space:
mode:
authorritsuka <[email protected]>2014-07-16 12:00:21 +0000
committerritsuka <[email protected]>2014-07-16 12:00:21 +0000
commit3bd8e012e3416963b89035f3212b632d9aa85958 (patch)
treed527d7282bb7eb1ca81f8b230390b040c1ccbbb1 /macosx/HBDVDDetector.m
parent0e165d0a096d606b52b1bcace1911c7d0c24be04 (diff)
MacGui: Replaced some deprecated functions in HBDVDDetector and ignored the QTKit deprecations warnings for now. Grouped some files in the Xcode project.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6233 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx/HBDVDDetector.m')
-rw-r--r--macosx/HBDVDDetector.m53
1 files changed, 17 insertions, 36 deletions
diff --git a/macosx/HBDVDDetector.m b/macosx/HBDVDDetector.m
index be2fbbe0d..f1fdd1bd7 100644
--- a/macosx/HBDVDDetector.m
+++ b/macosx/HBDVDDetector.m
@@ -10,6 +10,7 @@
#include <IOKit/IOKitLib.h>
#include <IOKit/storage/IOMedia.h>
#include <IOKit/storage/IODVDMedia.h>
+#include <DiskArbitration/DiskArbitration.h>
#import "HBDVDDetector.h"
@@ -79,48 +80,28 @@
return bsdName;
}
- OSStatus err;
- FSRef ref;
- err = FSPathMakeRef( (const UInt8 *) [path fileSystemRepresentation],
- &ref, NULL );
- if( err != noErr )
- {
- return nil;
- }
-
- // Get the volume reference number.
- FSCatalogInfo catalogInfo;
- err = FSGetCatalogInfo( &ref, kFSCatInfoVolume, &catalogInfo, NULL, NULL,
- NULL);
- if( err != noErr )
- {
- return nil;
- }
- FSVolumeRefNum volRefNum = catalogInfo.volume;
-
- // Now let's get the device name
- GetVolParmsInfoBuffer volumeParms;
- err = FSGetVolumeParms ( volRefNum, &volumeParms, sizeof( volumeParms ) );
+ NSURL *volumeURL = [NSURL fileURLWithPath:path];
- if( err != noErr )
- {
- return nil;
- }
+ // Create a DADiskRef
+ DASessionRef session = DASessionCreate(kCFAllocatorDefault);
+ DADiskRef disk = DADiskCreateFromVolumePath(kCFAllocatorDefault,
+ session,
+ (__bridge CFURLRef)volumeURL);
- // A version 4 GetVolParmsInfoBuffer contains the BSD node name in the vMDeviceID field.
- // It is actually a char * value. This is mentioned in the header CoreServices/CarbonCore/Files.h.
- if( volumeParms.vMVersion < 4 )
+ if ( disk )
{
- return nil;
+ CFDictionaryRef desc = DADiskCopyDescription(disk);
+ if ( desc )
+ {
+ // Get the bsd name from it
+ bsdName = [(NSString *)CFDictionaryGetValue(desc, kDADiskDescriptionMediaBSDNameKey) retain];
+ CFRelease(desc);
+ }
+ CFRelease(disk);
}
- // vMDeviceID might be zero as is reported with experimental ZFS (zfs-119) support in Leopard.
- if( !volumeParms.vMDeviceID )
- {
- return nil;
- }
+ CFRelease(session);
- bsdName = [[NSString stringWithUTF8String:(const char *)volumeParms.vMDeviceID] retain];
return bsdName;
}