Using an alias makes it easy to redirect the doodle folder elsewhere. I also like the robustness of aliases compared with symbolic links -- if the target folder is moved, the link usually survives.
We've used this mechanism in our product since OS8 and it's worked really well. The alias is created during the install. Until now, we've been using InstallerVise, but would like to move to PackageMaker.
The only way to create the alias is to use AppleScript talking with Finder.
tell application "Finder"
set macSrcPath to POSIX file "/Applications/MyProduct/doodle/doodle.tag" as text
set macDstFolder to POSIX file "/Library/Application Support/MyCompany/MyProduct" as text
make new alias at folder (macDstFolder as text) to (macSrcPath as alias) with properties {name: "doodle.tag alias"}
end tell
This usually works, but it occasionally fails. Here's what happens:
During development, I often drag a copy of the MyProduct folder to the trash and install a new copy. If a copy of the product is in the trash, the above code will point the alias at the version of the file in the trash, not the one in the Applications folder. In cmd-Info, Original is:
/Users/me/.Trash/MyProduct/doodle/doodle.tag
Of course, it should be:
/Applications/MyProduct/doodle/doodle.tag
I cannot figure out how to make it point to the correct file. The above code specifies the path explicitly. If I add
display alert macSrcPath
to the above code, it displays
Macintosh HD:Applications:MyProduct:doodle:doodle.tag
so the source variable is correct.
I've tried changing the last line to:
make new alias at folder (macDstFolder as text) to (macSrcPath) with properties {name: "doodle.tag alias"}
(I removed 'as alias' after macSrcPath). This made no difference. Same weird behavior.
Of course, if I create the alias manually, it works fine.
If I empty the trash, it works fine.
Leaving this problem in the product will cause tech support headaches. Does anyone know how to get 'make new alias' to always point to the file it is supposed to point to?
Thanks,
Joel May