rob*_*bor 3 macos cocoa dvd objective-c iokit
给定一条路径,在Mac OS X中,有没有办法告诉它是一个挂载的CD或DVD,而不是常规目录,常规文件,或挂载的DMG或其他可挂载的文件类型?具体来说,当用户直接提供路径或通过NSOpenPanel提供路径或将CD拖到应用程序上时,我想知道它是CD还是DVD.我需要在这些案件中采取特别行动.
查看Apple的VolumeToBSDNode示例代码.我相信它应该有你需要的代码位.
描述
显示如何遍历所有已装入的卷并检索每个卷的BSD节点名称(/ dev/disk*).该信息用于确定卷是否在CD,DVD或某些其他存储介质上.
正如Kent指出的那样,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));
+
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2691 次 |
| 最近记录: |