Re: Creating alias programatically
Re: Creating alias programatically
- Subject: Re: Creating alias programatically
- From: Rainer Brockerhoff <email@hidden>
- Date: Tue, 23 Sep 2008 19:54:14 -0300
At 15:12 -0700 23/09/08, email@hidden wrote:
>From: Ken Thomases <email@hidden>
>References: <email@hidden>
>In-Reply-To: <email@hidden>
>Date: Tue, 23 Sep 2008 15:40:47 -0500
>Message-ID: <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: chaitanya pandit <email@hidden>
>References: <email@hidden>
> <email@hidden>
> <email@hidden>
> <email@hidden>
> <email@hidden>
> <email@hidden>
>In-Reply-To: <email@hidden>
>Date: Wed, 24 Sep 2008 03:27:59 +0530
>Message-ID: <email@hidden>
>
>Here is what i did:
>...
> long handleSize = GetHandleSize((Handle)aliasHandle);
> int wrote = write(fd, &handleSize, sizeof(long));
> wrote = write(fd, *aliasHandle, handleSize);
> close(fd);
That's the error. An alias file isn't just an alias handle written out into the data fork.
You have to create a resource file (with a resource fork), the file's Finder flags should have the kIsAlias bit turned on, and then you save the alias Handle as resource ID#0 with type 'alis'. Details in <Resources.h>, if I recall correctly.
--
Rainer Brockerhoff <email@hidden>
Belo Horizonte, Brazil
"In the affairs of others even fools are wise
In their own business even sages err."
Weblog: http://www.brockerhoff.net/bb/viewtopic.php
_______________________________________________
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