You are welcome to use this method I wrote (as a category on NSString). It's from my JPEGDeux program. Make sure to #import <Carbon/Carbon.h> as well.
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>
<font color = brown>//returns a path to the file pointed at by self if self is an alias, self otherwise</font>
<font color = brown>//yes, we do follow chains of aliases</font>
<font color = brown>//returns nil if self cannot be resolved. Does not attempt to mount volumes.</font>
<font color = brown>//if isDir is not nil, returns whether or not the resolved file is a directory</font>
- (NSString*)resolveAliasesIsDir
BOOL*)pIsDir {
Boolean isDir, wasAlias;
FSRef ref;
OSStatus result;
result=FSPathMakeRef([self UTF8String], &ref, &isDir);
if (result != noErr) return nil;
if (isDir) {
if (pIsDir) *pIsDir=YES;
return self;
}
result=FSResolveAliasFileWithMountFlags(&ref, YES, &isDir, &wasAlias, kARMNoUI | kARMSearch);
if (pIsDir) *pIsDir=isDir;
if (result != noErr) return nil;
if (wasAlias) {
unsigned char pathBuff[<font color = blue>512</font>];
result=FSRefMakePath(&ref, pathBuff, sizeof pathBuff);
if (result != noErr) return nil;
return [NSString stringWithCString
athBuff];
}
return self;
}
</font>[/code]
Beware: while looking back over my code, I think it may have issues with aliases that refer to files with non-ASCII characters in their names.
-Peter