给定一个路径,在Mac OS X中,有没有办法来告诉它是一个安装CD或DVD,而不是一个普通的目录,普通文件,或安装DMG或其他安装文件类型?具体来说,我想知道这是否是一个CD或DVD时,用户直接提供的路径,或通过NSOpenPanel,或拖动CD上的应用程序。我需要在这些案件专项行动。

有帮助吗?

解决方案

检查出苹果的 VolumeToBSDNode 的示例代码。我相信它应该有你需要的代码位。

<强>描述

显示如何在所有安装的卷迭代和检索每个卷的BSD节点名称(的/ dev /磁盘*)。该信息被用于确定如果卷上的CD,DVD,或一些其他的存储介质。

作为肯特指出,在这个例子中,呼叫PBHGetVolParmsSync被弃用。下面是使用较新的功能的差异:

-            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));
+
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top