Danny Yoo writes: <cut>
I don't have a Macintosh available at the moment, so I can't test this, but I believe that the macfs.NewAliasMinimalFromFullPath() is the function that you're looking for:
I looked at that and didn't initially think that it was going to help but your saying it might be the thing made me look again. Though I don't know if I've got everything right, I do have a routine now that will make an alias of a folder. I don't understand the "relative" option yet, though. Those more in the know about the mac toolbox may see other things that I don't know as well. :-) Until the macostools.makealias is fixed, this is a workaround. Thanks for the nudge, Danny. And thanks for filing a bug report, Jack. /c #### import macfs from Carbon import Res # # Doesn't yet handle the relative option; I'm not sure what this # means for an alias yet. # def mkfolderalias(src, dst, relative=None): """Create an alias to a folder""" alias = macfs.NewAliasMinimalFromFullPath(dst) dstfss = alias.Resolve()[0] Res.FSpCreateResFile(dstfss, 'MACS', 'fdrp', -1) # make it point at the src and update the resource # {see Mac Lib Modules; v 2.2; sect 2.4.2 Alias Objects} # If the source is itself an alias, the new alias # will point at the same thing that the src alias is # pointing at. If the src is *not* a folder it will then # still point at the file but the icon will be a folder # icon until it is updated by the Finder (e.g. after # double clicking on it in the Finder). # alias.Update(src) h = Res.FSpOpenResFile(dstfss, 3) resource = Res.Resource(alias.data) resource.AddResource('alis', 0, '') Res.CloseResFile(h) # turn it into an alias icon; before doing this the # folder icon will be "busy and in use by the system" # dstfss = macfs.FSSpec(dst) dstfinfo = dstfss.GetFInfo() dstfinfo.Flags = dstfinfo.Flags|0x8000 # Alias flag dstfss.SetFInfo(dstfinfo) ####
participants (1)
-
Christopher Smith