Re: Resolving a alias w/o mounting file systems
Re: Resolving a alias w/o mounting file systems
- Subject: Re: Resolving a alias w/o mounting file systems
- From: "Timothy J. Wood" <email@hidden>
- Date: Mon, 17 Apr 2006 10:47:17 -0700
On Apr 17, 2006, at 10:41 AM, Pierre Bernard wrote:
Hi!
I would like to resolve Finder aliases in code. It appears that
there is no Cocoa API to do so.
Carbon has the AliasManager API which lets me resolve aliases using
FSResolveAliasFile()
The problem is that this function goes to mount server volumes to
which the alias may point. This has a time penalty (especially if
the server is unavailable) I am not willing to take.
How can I resolve an alias only if the original's volume is readily
available?
We use the following in OmniFoundation's OFAlias:
- (NSString *)pathAllowingUserInterface:(BOOL)allowUserInterface
missingVolume:(BOOL *)missingVolume;
{
// We want to allow the caller to avoid blocking if the volume
in question is not reachable. The only way I see to do that is to
pass the kResolveAliasFileNoUI flag to FSResolveAliasWithMountFlags.
This will cause it to fail immediately with nsvErr (no such volume).
FSRef target;
Boolean wasChanged;
OSErr result;
unsigned long mountFlags = kResolveAliasTryFileIDFirst;
if (!allowUserInterface)
mountFlags |= kResolveAliasFileNoUI;
if (missingVolume)
*missingVolume = NO;
result = FSResolveAliasWithMountFlags(NULL, _aliasHandle,
&target, &wasChanged, mountFlags);
if (result == noErr) {
CFURLRef urlRef = CFURLCreateFromFSRef(kCFAllocatorDefault,
&target);
NSString *urlString = (NSString *)CFURLCopyFileSystemPath
(urlRef, kCFURLPOSIXPathStyle);
CFRelease(urlRef);
return [urlString autorelease];
} else if (result == nsvErr) {
if (missingVolume)
*missingVolume = YES;
} else {
NSLog(@"FSResolveAliasWithMountFlags -> %d", result);
}
return nil;
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden