When you click on a file and choose Open With, but you don't choose Change All, your compute makes a special hidden list buried deep in the secret recesses of Mac OS X. This hidden list is consulted when you double-click a file. It will look at the list and say "Is the file that was just double-clicked on in this list?" If the answer is 'yes' it will open it with the program you specify. If the answer is 'no' it will open it with the default program for that app.[1]
So let's say you have a file called MyInformation.odt. Normally, ODT files open with Text Edit. You change MyInformation.odt to open with NeoOffice. The Mac makes a list, and on that list it says "MyInformation.odt opens with NeoOffice."
All good, so far. Now you make an alias to the file.
But now it gets sneaky. Now you have a new file, that's called "MyInformation.odt alias". You double-click on that. The Mac finds the reference to "MyInformation.odt" and goes to look up what program to use.
It consults its secret list. The list has "MyInformation.odt" on it...but it does not have "MyInformation.odt alias" on it! So it doesn't "count" as being in the list, and the Mac uses Text Edit to open the file.
What????
That's completely wrong. There is no secret list. When you Get Info→Open with: and
do not click on "Change All...", Finder adds a 'usro'(0) resource to the document's resource fork, creating the resource fork if necessary. The content of a 'usro' resource is what's called an "Alias Record", which is what an "alias" really is. In this case, the Alias Record points to the application you just selected.
(Alias Records are used all over the place in MacOS and in OS X. The Dock remembers which things you've put on the Dock by saving an Alias Record for each one. The ones you've marked to remain in the dock have their Alias Records written into Dock's preferences. Your "Recent Items" lists are lists of Alias Records. Creating an Alias File in Finder is merely one of the more visible uses of Alias Records; in particular, an
Alias File is a file that has an 'alis'(0) resource containing an
Alias Record. It's the Alias Record that embodies the magic that we blithely refer to as "an alias".)
If you double-click on an alias file in Finder, Finder begins by resolving the Alias Record it contains, to find the actual document. Once the document has been found
the alias file itself is no longer relevant. It has been used up, so to speak, and plays no further part in the process.
Now that the document has been found, Finder looks in it for a 'usro'(0) resource, and if one is present resolves it to find the application. (If there there were no 'usro'(0) resource, Finder would ask Launch Services to find the appropriate application. Launch Services does, indeed, consult "a special hidden list buried deep in the secret recesses of Mac OS X", but in our scenario we never get around to asking Launch Services which application to use. Had you chosen "Change All..", it would indeed be Launch Services' hidden secret file that got updated, but we're assuming you didn't, so that a 'usro'(0) resource got created instead.)
Finder launches the application, and passes it a list of Alias Records pointing to the documents it's supposed to open.
These Alias Records are constructed on the fly, and point directly to the documents. Even if you double-click on an alias file, the Alias Record that gets passed to the application
does not point to the alias file, nor is it extracted from the 'alis'(0) resource it contains.
I repeat: it makes absolutely no difference whether you double-click on a document or an an alias file that points to the document. In fact, a not infrequent plaint among beginning programmers, especially beginning AppleScripters, is that there is no way for the application to learn whether an Alias File was involved, let alone which one.
Either way, Finder
- Finds the document
- If you double-clicked on it, that's the one, or
- if you double-clicked on an alias file that points to it, the alias is resolved to find the document
- Finds the application
- If the document contains a 'usro'(0) resource, the contained Alias Record is resolved to find it
- Otherwise, Launch Services is asked to find a suitable application
- Finder makes a new Alias Record to the document itself
- The application is launched if it wasn't already running.
- The application is passed an 'open' AppleEvent that contains the Alias Record just created.
- The application resolves the Alias Record and opens the document.