[vlc-commits] macosx: replace Carbon implementation with its BSD counter-part

Felix Paul Kühne git at videolan.org
Fri Feb 2 17:31:06 CET 2018


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Fri Feb  2 17:30:38 2018 +0100| [535112f6c6cbc7810c510838cb0ebefb4a5282bb] | committer: Felix Paul Kühne

macosx: replace Carbon implementation with its BSD counter-part

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=535112f6c6cbc7810c510838cb0ebefb4a5282bb
---

 modules/gui/macosx/VLCStringUtility.m | 78 +++++++----------------------------
 1 file changed, 15 insertions(+), 63 deletions(-)

diff --git a/modules/gui/macosx/VLCStringUtility.m b/modules/gui/macosx/VLCStringUtility.m
index 4487187659..c564878838 100644
--- a/modules/gui/macosx/VLCStringUtility.m
+++ b/modules/gui/macosx/VLCStringUtility.m
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * VLCStringUtility.m: MacOS X interface module
  *****************************************************************************
- * Copyright (C) 2002-2014 VLC authors and VideoLAN
+ * Copyright (C) 2002-2018 VLC authors and VideoLAN
  * $Id$
  *
  * Authors: Jon Lech Johansen <jon-vl at nanocrew.net>
@@ -29,6 +29,9 @@
 #import "VLCMain.h"
 #import "CompatibilityFixes.h"
 
+#import <sys/param.h>
+#import <sys/mount.h>
+
 #import <IOKit/storage/IOMedia.h>
 #import <IOKit/storage/IOCDMedia.h>
 #import <IOKit/storage/IODVDMedia.h>
@@ -383,77 +386,26 @@ NSString *toNSStr(const char *str) {
 
 - (NSString *) getBSDNodeFromMountPath:(NSString *)mountPath
 {
-    OSStatus err;
-    FSRef ref;
-    FSVolumeRefNum actualVolume;
-    err = FSPathMakeRef ((const UInt8 *) [mountPath fileSystemRepresentation], &ref, NULL);
-
-    // get a FSVolumeRefNum from mountPath
-    if (noErr == err) {
-        FSCatalogInfo   catalogInfo;
-        err = FSGetCatalogInfo (&ref,
-                                kFSCatInfoVolume,
-                                &catalogInfo,
-                                NULL,
-                                NULL,
-                                NULL
-                                );
-        if (noErr == err)
-            actualVolume = catalogInfo.volume;
-        else
-            return @"";
-    }
-    else
+    struct statfs stf;
+    int ret = statfs([mountPath fileSystemRepresentation], &stf);
+    if (ret != 0) {
         return @"";
-
-    GetVolParmsInfoBuffer volumeParms;
-    err = FSGetVolumeParms(actualVolume, &volumeParms, sizeof(volumeParms));
-    if (noErr == err) {
-        NSString *bsdName = [NSString stringWithUTF8String:(char *)volumeParms.vMDeviceID];
-        return [NSString stringWithFormat:@"/dev/r%@", bsdName];
     }
 
-    return @"";
+    return [NSString stringWithFormat:@"r%s", stf.f_mntfromname];
 }
 
 - (NSString *)getVolumeTypeFromMountPath:(NSString *)mountPath
 {
-    OSStatus err;
-    FSRef ref;
-    FSVolumeRefNum actualVolume;
-    NSString *returnValue;
-    err = FSPathMakeRef ((const UInt8 *) [mountPath fileSystemRepresentation], &ref, NULL);
-
-    // get a FSVolumeRefNum from mountPath
-    if (noErr == err) {
-        FSCatalogInfo   catalogInfo;
-        err = FSGetCatalogInfo (&ref,
-                                kFSCatInfoVolume,
-                                &catalogInfo,
-                                NULL,
-                                NULL,
-                                NULL
-                                );
-        if (noErr == err)
-            actualVolume = catalogInfo.volume;
-        else
-            goto out;
-    }
-    else
-        goto out;
-
-    GetVolParmsInfoBuffer volumeParms;
-    err = FSGetVolumeParms(actualVolume, &volumeParms, sizeof(volumeParms));
-
-    CFMutableDictionaryRef matchingDict;
-    io_service_t service;
-
-    if (!volumeParms.vMDeviceID) {
-        goto out;
+    struct statfs stf;
+    int ret = statfs([mountPath fileSystemRepresentation], &stf);
+    if (ret != 0) {
+        return @"";
     }
 
-    matchingDict = IOBSDNameMatching(kIOMasterPortDefault, 0, volumeParms.vMDeviceID);
-    service = IOServiceGetMatchingService(kIOMasterPortDefault, matchingDict);
+    CFMutableDictionaryRef matchingDict = IOBSDNameMatching(kIOMasterPortDefault, 0, stf.f_mntfromname);
+    io_service_t service = IOServiceGetMatchingService(kIOMasterPortDefault, matchingDict);
+    NSString *returnValue;
 
     if (IO_OBJECT_NULL != service) {
         if (IOObjectConformsTo(service, kIOCDMediaClass))



More information about the vlc-commits mailing list