這應該讓你的大部分東西你正在尋找(約知掛載點的信息。):
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