这应该让你的大部分东西你正在寻找(约知挂载点的信息。):
NSWorkspace *ws = [NSWorkspace sharedWorkspace];
NSArray *vols = [ws mountedLocalVolumePaths];
NSFileManager *fm = [NSFileManager defaultManager];
for (NSString *path in vols)
{
NSDictionary* fsAttributes;
NSString *description, *type, *name;
BOOL removable, writable, unmountable, res;
NSNumber *size;
res = [ws getFileSystemInfoForPath:path
isRemovable:&removable
isWritable:&writable
isUnmountable:&unmountable
description:&description
type:&type];
if (!res) continue;
fsAttributes = [fm fileSystemAttributesAtPath:path];
name = [fm displayNameAtPath:path];
size = [fsAttributes objectForKey:NSFileSystemSize];
NSLog(@"path=%@\nname=%@\nremovable=%d\nwritable=%d\nunmountable=%d\n"
"description=%@\ntype=%@, size=%@\n\n",
path, name, removable, writable, unmountable, description, type, size);
}
+1对于更多的OOP比我的答案。 :) – 2010-08-23 07:59:07
谢谢。这正是我需要:) 我没有找到一种方法来显示在Windows上的'友好名称'的信息,但我想有一种方法可以在Mac上执行它(我认为这是这里的描述字段,但它是一个文件系统)。 如果你知道如何检索该信息,请告诉我...否则,这是真棒:) – Amy 2010-08-24 15:24:25
@emi:嗯,我不知道。我甚至找不到使用I/O Registry Explorer(位于'/ Developer/Applications/Utilities')的东西。 – 2010-08-24 16:57:38