In the WWDC discussion on Firmlinks, it says they are "Not expected to be noticed by a user or an application".
I don't see how creating multiple aliases to a folder, and providing no way for developer to resolve them to for the purposes of comparison, is expected *not* to cause serious headaches.
Consider lower level calls like LSGetApplicationForInfo, which may not return a "firmlinked" response vs. an NSOpenPanel result, which does seem to return a "firmlinked" value.
I've prepared a simple method here for testing, so you can see the challenge. Stripping off the firmlinked prefix is a possibility too, but it's clunky.
+ (NSURL *)exampleNotWorking
{
NSURL *defaultUrl = [NSURL fileURLWithPath:@"/Applications/Notes.app"];
NSURL *defaultUrltest1 = [defaultUrl URLByResolvingSymlinksInPath];
NSURL *defaultUrltest2 = [defaultUrl URLByStandardizingPath];
NSLog(@"Default application set to: %@", defaultUrl.path);
NSLog(@"Attempts to standardize path: %@, %@", defaultUrltest1.path, defaultUrltest2.path);
NSOpenPanel *panel = [NSOpenPanel openPanel];
[panel setTitle:NSLocalizedString(@"Choose Application", nil)];
[panel setPrompt:NSLocalizedString(@"Select", nil)];
[panel setAllowedFileTypes:@[ @"app" ]];
[panel setDirectoryURL:defaultUrl];
[panel setCanChooseFiles:YES];
[panel setCanChooseDirectories:NO];
[panel setAllowsMultipleSelection:NO];
if ([panel runModal] == NSModalResponseOK)
{
NSURL *result = [[panel URLs] firstObject];
NSURL *resultTest1 = [result URLByResolvingSymlinksInPath];
NSURL *resultTest2 = [result URLByStandardizingPath];
NSLog(@"Selection from NSOpenPanel: %@", result.path);
NSLog(@"Attempts to standardize path: %@, %@", resultTest1.path, resultTest2.path);
// how to compare result with defaultUrl??
// even test1, test2 don't behave properly (they remove /private, but not /System... etc.)
return result;
}
return nil;
}