How do I know if this path is set for removable media in Mac OS X?

Given the path in Mac OS X, is there any way of saying that this is a mounted CD or DVD, unlike a regular directory, a regular file, or a mounted DMG or other type of mounted file? In particular, I would like to know if it is a CD or DVD when the user sends the path directly or via NSOpenPanel or drag and drop the CD into the application. I need to take special action in these cases.

+3
source share
1 answer

Check out the Apple VolumeToBSDNode sample code . I believe that it should have the necessary bits of code.

Description

Shows how to iterate over all mounted volumes and retrieve the BSD node name (/ dev / disk *) for each volume. This information is used to determine if the volume is on a CD, DVD, or other media.

As Kent points out, the call PBHGetVolParmsSyncin this example is out of date. Here diff is used to use the newer function:

-            HParamBlockRec pb;

-            // Use the volume reference number to retrieve the volume parameters. See the documentation
-            // on PBHGetVolParmsSync for other possible ways to specify a volume.
-            pb.ioParam.ioNamePtr = NULL;
-            pb.ioParam.ioVRefNum = actualVolume;
-            pb.ioParam.ioBuffer = (Ptr) &volumeParms;
-            pb.ioParam.ioReqCount = sizeof(volumeParms);
-            
-            // 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.
-            result = PBHGetVolParmsSync(&pb);
+            // Use FSGetVolumeParms instead of the deprecated PBHGetVolParmsSync
+            result = FSGetVolumeParms(actualVolume, &volumeParms, sizeof(volumeParms));
+
+6
source

Source: https://habr.com/ru/post/1722284/


All Articles