On Jun 5, 2005, at 7:09 PM, Lee Cullens wrote:
> One of my little utilities needs to know when it encounters links/
> aliases.
>
> I can of course detect a Unix symbolic link with os.path.islink
> ('path') and determine what it points to with os.readlink('path'),
> but an Aqua alias only triggers os.isfile and it has a size of zero.
> The size is not a reliable indicator though and I was wondering how
> (in Python) to detect such and determine what it points to.
>
> Is this one of those OS unique things where I need to get into the
> dev tools to resolve? I've been putting such off till I get into
> ObjC, since Bob said I would understand the interfaces better then.
Aliases have nothing to do with Objective-C, they're only dealt with
from Carbon.
import os
from Carbon.File import FSResolveAliasFile, FSRef
def resolve_alias(path):
# resolve an alias, if not an alias then it will just return the
# given path.
return FSResolveAliasFile(path, True)[0].as_pathname()
def is_alias(path):
# return 1 if an alias, 0 otherwise
return FSRef(path)[0]
-bob
_______________________________________________
Pythonmac-SIG maillist - [email protected]
http://mail.python.org/mailman/listinfo/pythonmac-sig