OSDN Git Service

Macgui: fix issue where choosing an srt subtitle file would fail to autmatically...
[handbrake-jp/handbrake-jp-git.git] / macosx / HBDVDDetector.m
index 966e812..81a8545 100644 (file)
@@ -3,7 +3,7 @@
  * 8/17/2007
  * 
  * This file is part of the HandBrake source code.
- * Homepage: <http://handbrake.m0k.org/>.
+ * Homepage: <http://handbrake.fr/>.
  * It may be used under the terms of the GNU General Public License.
  */
 
 - (NSString *)bsdNameForPath
 {
     OSStatus err;
-       FSRef ref;
-       err = FSPathMakeRef( (const UInt8 *) [path fileSystemRepresentation],
+    FSRef ref;
+    err = FSPathMakeRef( (const UInt8 *) [path fileSystemRepresentation],
                          &ref, NULL ); 
-       if( err != noErr )
+    if( err != noErr )
     {
         return nil;
     }
     }
     FSVolumeRefNum volRefNum = catalogInfo.volume;
 
-       // Now let's get the device name
-       GetVolParmsInfoBuffer volumeParms;
-    // PBHGetVolParmsSync is deprecated, but still needed for 10.4 compatibility
-    #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
-       HParamBlockRec pb;
-       pb.ioParam.ioNamePtr = NULL;
-       pb.ioParam.ioVRefNum = volRefNum;
-       pb.ioParam.ioBuffer = (Ptr) &volumeParms;
-       pb.ioParam.ioReqCount = sizeof( volumeParms );
-       err = PBHGetVolParmsSync( &pb );
-    #else
-    // Let's use FSGetVolumeParms
+    // Now let's get the device name
+    GetVolParmsInfoBuffer volumeParms;
     err = FSGetVolumeParms ( volRefNum, &volumeParms, sizeof( volumeParms ) );
-    #endif
 
     if( err != noErr )
     {
         return nil;
     }
 
-       // 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.
-    return [NSString stringWithCString:(char *)volumeParms.vMDeviceID];
+    // 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 )
+    {
+        return nil;
+    }
+
+    // vMDeviceID might be zero as is reported with experimental ZFS (zfs-119) support in Leopard.
+    if( !volumeParms.vMDeviceID )
+    {
+        return nil;
+    }
+
+    return [NSString stringWithUTF8String:(const char *)volumeParms.vMDeviceID];
 }