Re: Creating alias programatically
Re: Creating alias programatically
- Subject: Re: Creating alias programatically
- From: Ken Thomases <email@hidden>
- Date: Tue, 23 Sep 2008 18:15:03 -0500
On Sep 23, 2008, at 5:54 PM, Rainer Brockerhoff wrote:
At 15:12 -0700 23/09/08, email@hidden wrote:
From: Ken Thomases <email@hidden>
Apple has never officially supported applications creating alias
files. In fact, the documentation often refers to them as "Finder
alias files" because, as far as Apple is concerned, only the Finder
should ever be creating them. See the section "Working With Finder
Alias Files" in the Alias Manager Reference, and notice that there
are only functions for examining and reading alias files, not
creating them. For that reason, the supported way to create an
alias file is to use Apple Events to ask the Finder to create it
for you.
That's news to me... I really can't recall right now where the alias
file format was officially documented, but in the Classic days it
was quite acceptable to create them yourself. (They were invented
before Apple Events, after all ;-) )
From the legacy Inside Macintosh <http://developer.apple.com/documentation/mac/Toolbox/Toolbox-459.html
>:
Alias files are created and managed by the user through the Finder.
Although your application shouldn't create alias files or change
users' aliases, your application can create and use its own alias
records for storing identifying information about files or
directories.
From legacy Technical Note TB535: Finder Q&Aa <http://developer.apple.com/technotes/tb/tb_535.html
>:
Creating a Finder alias
Date Written: 6/14/91
Last reviewed: 6/14/93
How can I get my program to create a Finder alias?
Finder aliases are one aspect of the Macintosh human interface
considered "reserved for users." The format is intentionally
undefined because it is subject to change, and because alias files
should be neither created nor altered by applications. The Finder is
the user's domain, and aliases are a user convenience. If you are
inclined to create an alias file, rethink your application design.
Would clear instructions to users on how to make the aliases be
adequate? Are the files your application needs too scattered?
If some demon still drives you to make alias files, the safest way
to do it is by issuing Apple events to the Finder. The particular
Finder event for making an alias is 'FNDR' 'sali'; it is documented
in the Apple Event registry. Since this Finder event does not return
either the name of or an alias to the new alias file, nor is there a
Finder event for identifying the currently selected icons, moving
the alias file elsewhere will be problematic.
The unsafe way to make an alias file is to create the file yourself.
The format of alias files is undocumented; there is no guarantee
that any alias files created by your application will always work.
At present, you can construct an alias to a document by getting a
handle to an alias with a NewAlias call, creating a resource file
with the same creator and file type as the original file, adding the
alias as a resource of type 'alis' and ID 0, and setting bit 15 of
the file's Finder flags. Aliases to applications have the file type
'adrp'; folder, volume, and system file aliases use other special
file types. Finally, alias files should have the same custom icons
as their targets.
Once again, DTS urges that you not create alias files from within an
application.
Just because the format was documented doesn't mean that Apple
supported the creation of alias files by third-party applications.
Regards,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden