この問題を解決するには、ここで私が思い付いた最後の関数である、Apple Dev Forums上で示唆された:FSPathMakeRef、FSGetCatalogInfoとFSCopyURLForVolumeは、マックOS X 10.8から廃止されましたので、
- (NSURL *)volumeMountPathFromPath:(NSString *)path{
NSString *mountPath = nil;
NSString *testPath = [path copy];
while(![testPath isEqualToString:@"/"]){
NSURL *testUrl = [NSURL fileURLWithPath:testPath];
NSNumber *isVolumeKey;
[testUrl getResourceValue:&isVolumeKey forKey:NSURLIsVolumeKey error:nil];
if([isVolumeKey boolValue]){
mountPath = testPath;
break;
}
testPath = [testPath stringByDeletingLastPathComponent];
}
if(mountPath == nil){
return nil;
}
NSString *pathCompointents = [path substringFromIndex:[mountPath length]];
FSRef pathRef;
FSPathMakeRef((UInt8*)[path fileSystemRepresentation], &pathRef, NULL);
FSCatalogInfo catalogInfo;
OSErr osErr = FSGetCatalogInfo(&pathRef, kFSCatInfoVolume|kFSCatInfoParentDirID,
&catalogInfo, NULL, NULL, NULL);
FSVolumeRefNum volumeRefNum = 0;
if(osErr == noErr){
volumeRefNum = catalogInfo.volume;
}
CFURLRef serverLocation;
OSStatus result = FSCopyURLForVolume(volumeRefNum, &serverLocation);
if(result == noErr){
NSString *fullUrl = [NSString stringWithFormat:@"%@%@",
CFURLGetString(serverLocation), pathCompointents];
return [NSURL URLWithString:fullUrl];
}else{
NSLog(@"Error getting the mount path: %i", result);
}
return nil;
}
「FSCopyURLForVolume」は、実際にはボリュームの完全なURLを提供します。そのボリューム上のアイテムのURLが必要な場合は、その目的のためにNSURLのメソッドまたはCFURLの関数を使用して、自分で作成する必要があります。 –