Somewhere in the E.U., le 23/06/2005

     Bonjour

         Thank you for all the replies.


On 21 juin 2005, at 22:35, [EMAIL PROTECTED] wrote:

> From: Bob Ippolito <[EMAIL PROTECTED]>
> Date: 21 juin 2005 17:49:59 HAEC
> To: Hubert Holin <[EMAIL PROTECTED]>
> Cc: pythonmac-sig@python.org
> Subject: Re: [Pythonmac-SIG] Finding what a broken alias refers to.
>
>
> 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.

         Well, I wanted a project which might yield some useful  
result as well. I agree that Carbon is not the most pleasant  
technology to work with.

>>      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.

         I have indeed used FSIsAliasFile to determine if it's an  
alias. I just wanted to then use an OS-supplied method to see where  
it pointed rather than investigate what I fear has become an opaque  
type. I see that Hamish Sanderson has come to my rescue (see below)  
by elaborating your point!

>>      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

         A question: I'd much, much rather use C++ than C (and never  
mind Objective-C). I have some idea of how to write Python extensions  
in C++, using Boost.Python. From reading what little documentation  
there is on Objective-C++, I see there are possible issues between  
the C++ and Objective-C runtimes. If I build a C++ extension and  
intend to use it along with PyObjC, am I inviting trouble ;-)   ?


> From: Chinook <[EMAIL PROTECTED]>
> Date: 21 juin 2005 18:20:07 HAEC
> To: pythonmac-sig@python.org
> Subject: Re: [Pythonmac-SIG] Finding what a broken alias refers to.
> Reply-To: [EMAIL PROTECTED]
>
>
> On Tue, 21 Jun 2005 11:21:17 -0400, Hubert Holin wrote
> (in article <[EMAIL PROTECTED]>):

[SNIP same as above]

>
> Here is a snippet from one of my utilities that might help.
>
>  # deal with directory item relative to type
>           if os.path.islink(dlfpath):
>
>             # directory item a symbolic link, generate row of cells
>             csvline = _cellpos(dlfpath, alvl, blvl, clvl)
>             # identify as link with path
>             lptr = '#Sym Link > ' + os.readlink(dlfpath)
>             csvline = csvline + '"' + lptr + '"'
>
>           elif FSResolveAliasFile(dlfpath, 1)[2]:
>
>             # directory item an Aqua alias, generate row of cells
>             csvline = _cellpos(dlfpath, alvl, blvl, clvl)
>             # identify as alias with target
>             lptr = '#Alias > ' + FSResolveAliasFile(dlfpath,
> 1)[0].as_pathname()
>             csvline = csvline + '"' + lptr + '"'
>
>
> Lee C

         Thank you for the suggestion. May I ask where "_cellpos" is  
documented? Yes, I am a newbee in more fields than one :-)   .


On 22 juin 2005, at 12:00, [EMAIL PROTECTED] wrote:
>
> From: has <[EMAIL PROTECTED]>
> Date: 22 juin 2005 01:39:32 HAEC
> To: pythonmac-sig@python.org
> Subject: Re: [Pythonmac-SIG] Finding what a broken alias refers to.
>
>
> Hubert Holin wrote:
>
>
>>     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.
>>
>
> As Bob says, you want to create a new Alias out of the alias file's  
> alis resource, e.g.:
>
> from Carbon.File import FSRef, Alias
> from Carbon.Res import *
>
> f = FSRef("/Users/has/a 'broken' Finder alias file")
>
> resfile = FSOpenResFile(f, 1)
> data = Get1IndResource('alis', 1).data
> CloseResFile(resfile)
> alias = Alias(rawdata=data)
>
> To get any useful data out of this 'broken' alias you'll have to  
> get your hands dirty though.

         Yes, well, as this is mostly a learning experience (with  
hopefully useful output), I try to see just how much functionality I  
can get. Already listing the broken aliases (which I have managed) is  
useful, at least for me.

>>     Likewise, the Alias Manager functions FSMatchAlias and
>> FSMatchAliasNoUI seem not to be wrapped.
>>
>
> Ditto FSCopyAliasInfo. Unfortunately I don't think Python's Carbon  
> wrappers have been updated much since their creation back in pre-OS  
> X days. You could probably patch up a copy yourself without much  
> trouble; it's a slightly hackish solution, but not that hard to do  
> (I've done it myself and my C's rubbish).
>
> HTH
>
> has
> -- 
> http://freespace.virgin.net/hamish.sanderson/

         Is there a way I can contribute (using some of the time  
slots I now try to put aside for Boost and the unreasonable number of  
things I intend to do)?

     Merci

             Hubert Holin



_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Reply via email to