Re: Alias Switches allegiance
Re: Alias Switches allegiance
- Subject: Re: Alias Switches allegiance
- From: Andrew Oliver <email@hidden>
- Date: Mon, 22 Jan 2007 08:44:57 -0800
On Jan 22, 2007, at 8:09 AM, Adam Bell wrote: I'm confused about the rules for an alias. If I comment out the two indicated lines, BBEdit opens the file Test2; the one I moved and renamed -- expected behavior.
If I run the two lines, i.e. create a new file with the same name as the original in the same place the original was, then BBEdit opens the new one -- i.e. the alias has switched back.
What are the rules here?
----- set F to alias ((path to desktop as text) & "Test") set fld to alias ((path to desktop as text) & "TestF:") tell application "Finder" move F to folder fld set name of F to "Test2" end tell -- Try with and without the following two lines -- i.e. replace the original. set N to open for access ((path to desktop as text) & "Test") close access N -- end trial tell application "BBEdit" to open F
It's been a while, but I'm pretty sure this is the expected behavior.
When resolving aliases, the OS takes several steps to find the file in question. First it looks at the path, if the path matches a file then it assumes that's the file you're after. If it doesn't match it uses some kind if internal file ID to track where the original file was moved to. Since the file ID is persistent it can follow a file even if moved or renamed.
This was always the idea back in the days (System 7? 8? 9?) when aliases were introduced - it allows you to move files around and still have the OS find them. It was always one of the advantages over Windows shortcuts and UNIX symlinks, both of which rely solely on file paths to find the file.
It's also the reason why you can't have an alias object that points to an invalid path/missing file - the system can't extract the file ID which is needed to track the file.
Andrew :) |
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/mailman//archives/applescript-users
This email sent to email@hidden