在 Objective C(或 Swift)中,我需要确定挂载的卷是否是磁盘映像(从 .dmg 文件挂载)。
类似的问题让我想到了NSURL Volume Property Keys,但它们似乎都没有给出卷的类型/协议。
diskutil
但是,我可以在下面的终端功能中看到这些信息Protocol
:
~/Temp$ diskutil info /dev/disk8
Device Identifier: disk8
Device Node: /dev/disk8
Part of Whole: disk8
Device / Media Name: Apple UDIF read-only Media
Volume Name: Not applicable (no file system)
Mounted: Not applicable (no file system)
File System: None
Content (IOContent): GUID_partition_scheme
OS Can Be Installed: No
Media Type: Generic
Protocol: Disk Image <=== THIS IS WHAT I WANT
SMART Status: Not Supported
Total Size: 5.2 MB (5242880 Bytes) (exactly 10240 512-Byte-Units)
Volume Free Space: Not applicable (no file system)
Device Block Size: 512 Bytes
Read-Only Media: Yes
Read-Only Volume: Not applicable (no file system)
Ejectable: Yes
Whole: Yes
Internal: No
OS 9 Drivers: No
Low Level Format: Not supported
编辑:通过对 NSWorkspace 的包含类别扩展,找到了一些至少用于执行此操作的代码。但是,它是 ARC 之前的版本,我不确定它是否仍然有效。
通过其他问题的部分答案找到它..