[Pythonmac-SIG] AppleEvents in MacPython 2.3?
bob at redivi.com
Mon Aug 11 20:58:08 EDT 2003
On Monday, Aug 11, 2003, at 19:10 America/New_York, Mark Day wrote:
> On Monday, August 11, 2003, at 3:15 PM, Bob Ippolito wrote:
>> On Monday, Aug 11, 2003, at 17:47 America/New_York, Larry Meyn wrote:
>>> On a related subject of colon separated AppleScript paths, how does
>>> one get the name of the root disk for generating absolute OS 9
>>> style (colon separated) paths? The abspath function from the
>>> macpath module doesn't work under OS X , because it uses os.getcwd()
>>> which returns a "/" delimited path. Are some nice functions that
>>> someone has written that can convert between the two path styles
>>> under OS X?
>> import Carbon.File
>> print Carbon.File.FSRef('/').FSGetCatalogInfo(0)
>> # looks like the full unicode name for the volume.. but maybe OS9
>> colon paths use the FSSpec paths?
> Close. In general, you convert the POSIX-style path to an FSRef (in
> Carbon this would be FSPathMakeRef; in Python you can also use
> Carbon.File.FSRef()). Then, call FSGetCatalogInfo and get the FSSpec.
> Look inside the FSSpec for the name. That's the name used by
> traditional Mac OS 9 style paths. (Note that there is no such thing
> as a Unicode path as far as the Carbon File Manager is concerned).
> Here's what you'd use to get just the name:
> print Carbon.File.FSRef('/').FSGetCatalogInfo(0).as_tuple()
> The first  gets the FSSpec output from FSGetCatalogInfo. The
> second  gets the name out of the FSSpec.
I thought the FSRef was capable of long utf8 file names, and it was my
guess that's what FSGetCatalogInfo(0) was?
More information about the Pythonmac-SIG