This should go something like this:
+ (NSString*)volumeNameForPath:(NSString *)inPath
{
HFSUniStr255 volumeName;
FSRef volumeFSRef;
unsigned int volumeIndex = 1;
while (FSGetVolumeInfo(kFSInvalidVolumeRefNum, volumeIndex++, NULL, kFSVolInfoNone, NULL, &volumeName, &volumeFSRef) == noErr) {
NSURL *url = [(NSURL *)CFURLCreateFromFSRef(NULL, &volumeFSRef) autorelease];
NSString *path = [url path];
if ([inPath hasPrefix:path]) {
return [NSString stringWithCharacters:volumeName.unicode length:volumeName.length]
}
}
return nil;
}
source
share