的磁盤映像(DMG)從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
編輯:找到some code至少用於執行此操作,通過this included category extension to NSWorkspace裝置。但是,它是ARC之前,我不知道它是否仍然有效。
通過this partial answer其他問題找到了..
我沒有嘗試過,但NSURLVolumeIsEjectableKey可能與NSURLVolumeIsRemovableKey結合呢?只是一個想法。 –
@MartinR謝謝!不過,我認爲這也會吸引可移動的HD和SSD驅動器,這是我想要檢測的驅動器。 (現在,我在打開每個dmg安裝程序時都會收到誤報。) –