我想获取在 OS X 下使用 Cocoa/Objective-C 无法安装/可弹出的驱动器列表。
我希望 NSWorkspace getFileSystemInfoForPath::::: 能帮助我:
NSArray* listOfMedia = [[NSWorkspace sharedWorkspace] mountedLocalVolumePaths];
NSLog(@"%@", listOfMedia);
for (NSString* volumePath in listOfMedia)
{
BOOL isRemovable = NO;
BOOL isWritable = NO;
BOOL isUnmountable = NO;
NSString* description = [NSString string];
NSString* type = [NSString string];
BOOL result = [[NSWorkspace sharedWorkspace] getFileSystemInfoForPath:volumePath
isRemovable:&isRemovable
isWritable:&isWritable
isUnmountable:&isUnmountable
description:&description
type:&type];
NSLog(@"Result:%i Volume: %@, Removable:%i, W:%i, Unmountable:%i, Desc:%@, type:%@", result, volumePath, isRemovable, isWritable, isUnmountable, description, type);
}
输出:
...
Result:1 Volume: /Volumes/LR Photos, Removable:0, W:1, Unmountable:0, Desc:hfs, type:hfs
...
“LR Photos”是一个外部驱动器(通过 Thunderbolt 连接),应该是可移动和/或不可安装的(或者,至少我认为它应该是)。:)
我应该以不同的方式解决这个问题吗?
提前致谢!