[Pythonmac-SIG] Finding what a broken alias refers to.

Bob Ippolito bob at redivi.com
Tue Jun 21 17:49:59 CEST 2005


On Jun 21, 2005, at 11:21 AM, Hubert Holin wrote:

>      For my first Python steps on the Mac, I am trying to find
> information on all broken aliases in a folder hierarchy (i.e. aliases
> which were created thru the Finder and which no longer reference an
> existing file or folder). While I am able to find the aliases which
> are broken, I would like to go a step further, and indicate *what*
> the alias thinks it is referencing (the "original" item in the Finder
> info), and I am encountering some problem.

This is not a good first project.  Using Carbon isn't very  
straightforward from any language.

>      It would seem that the best function to get that information is
> thru the FSFollowFinderAlias function of the Alias Manager, but
> unfortunately the only version which is wrapped is a member of the
> Alias class, which I have not found a way to use, as all I have is an
> instance of FSRef.

I think you have to use FSIsAliasFile to determine if it's an alias,  
and if so, then you load in the alias resource and and create an  
Alias out of that.  Carbon is painful.

>      Likewise, the Alias Manager functions FSMatchAlias and
> FSMatchAliasNoUI seem not to be wrapped.
>
>      What can I do, short of writing a C++ extension?

Writing a C extension or using the FFI available in PyObjC or ctypes  
are the only ways to bridge unwrapped functions.

-bob



More information about the Pythonmac-SIG mailing list