]> granicus.if.org Git - handbrake/commitdiff
MacGui: Used a different api in HBDVDDetector to avoid DiskArbitration crashes.
authorritsuka <damiog@gmail.com>
Sat, 19 Jul 2014 08:22:28 +0000 (08:22 +0000)
committerritsuka <damiog@gmail.com>
Sat, 19 Jul 2014 08:22:28 +0000 (08:22 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6238 b64f7644-9d1e-0410-96f1-a4d463321fa5

macosx/HBDVDDetector.m

index 97b4802a12ced33114e7a51621ecd42bb100ee24..6d12ed64e03af329636d3138df14acb06e7fd3e7 100644 (file)
@@ -10,7 +10,7 @@
 #include <IOKit/IOKitLib.h>
 #include <IOKit/storage/IOMedia.h>
 #include <IOKit/storage/IODVDMedia.h>
-#include <DiskArbitration/DiskArbitration.h>
+#include <sys/mount.h>
 
 #import "HBDVDDetector.h"
 
         return bsdName;
     }
 
-    NSURL *volumeURL = [NSURL fileURLWithPath:path];
+    struct statfs s;
+    statfs([path fileSystemRepresentation], &s);
 
-    // Create a DADiskRef
-    DASessionRef session = DASessionCreate(kCFAllocatorDefault);
-    DADiskRef disk = DADiskCreateFromVolumePath(kCFAllocatorDefault,
-                                                session,
-                                                (CFURLRef)volumeURL);
+    bsdName = [NSString stringWithUTF8String:s.f_mntfromname];
 
-    if ( disk )
+    if ([bsdName hasPrefix:@"/dev/"])
     {
-        CFDictionaryRef desc = DADiskCopyDescription(disk);
-        if ( desc )
-        {
-            // Get the bsd name from it
-            bsdName = [(NSString *)CFDictionaryGetValue(desc, kDADiskDescriptionMediaBSDNameKey) retain];
-            CFRelease(desc);
-        }
-        CFRelease(disk);
+        bsdName = [bsdName stringByReplacingCharactersInRange:NSMakeRange(0, 5) withString:@""];
     }
 
-    CFRelease(session);
-
-    return bsdName;
+    return [bsdName retain];
 }