[Pythonmac-SIG] alias icon, updating

C Smith smichr at hotmail.com
Sat Mar 20 22:17:25 EST 2004


I'm  working on a few file/alias related problems right now and after 
visiting the ADC site and downloading File and Alias pdfs, I haven't 
yet been able to overcome a few hurdles. Can anyone help?

1) I would like to be able to fix broken aliases.  The following will 
create a broken alias:

Start with a file named foo in a folder and another file named fee on 
the desktop. Now...
	create alias of fee on the desktop
	change its name to foo
	opt-drag foo from the folder onto the desktop to replace it
		the alias is now broken

The Apple docs say that an alias uses an id and a path to try resolve 
an alias. I suppose the alias is now broken because a file with a new 
ID and name has been put in place of fee.  Am I correct is saying that 
there is no way to unambiguosly repair the alias at this point?

Q: How can I find out the name of the original file to which the alias 
used to point?

2) the macostools.mkalias function creates a plain vanilla alias icon; 
the old version of macostools.mkalias created the right type of icon 
for an alias but it uses a slightly different method than the new 
version. Does anyone know what info needs to be added to the Alias 
itself to get the right icon so the new macostools works better?

I was trying to figure out how to update Alias information but am not 
sure how to get the handle to an alias.  I thought maybe the "h" below 
was such a handle (I copied that from the mkalias function) but it 
doesn't work.
###
 >>> from Carbon import File
 >>> from Carbon import Res
 >>> fsr=File.FSRef('/Users/csmith/Desktop/f')
 >>> dt=File.FSRef('/Users/csmith/Desktop/')
 >>> h = Res.FSpOpenResFile(File.FSSpec(a), 3)
 >>> File.FSUpdateAlias(dt,fsr,h)
Traceback (most recent call last):
   File "<input>", line 1, in ?
TypeError: Alias required
###
How do I get the Alias that is required by FSUpdateAlias?

Thanks for any help,
/c





More information about the Pythonmac-SIG mailing list