[Pythonmac-SIG] converting file paths between HFS and POSIX
formats
Nicholas Riley
njriley at uiuc.edu
Fri Apr 22 19:24:57 CEST 2005
On Fri, Apr 22, 2005 at 05:08:47PM +0100, has wrote:
> I'm kinda leery of using MacPython's CF wrapper as it's a bit buggy in places. Still your example looks like it works ok - good suggestion, thanks.
>
> One bit I'm not sure about though - if I run this:
>
> u = toCF('A Non-mounted Drive:').CFURLCreateWithFileSystemPath(kCFURLHFSPathStyle, False)
>
> print u.CFURLCopyFileSystemPath(kCFURLPOSIXPathStyle).toPython()
>
> I get '/A Non-mounted Drive' whereas I was assuming it should be
> '/Volumes/A Non-mounted Drive' - is that correct?
>>> u = toCF('Data:').CFURLCreateWithFileSystemPath(kCFURLHFSPathStyle, False)
>>> u.CFURLCopyFileSystemPath(kCFURLPOSIXPathStyle).toPython()
u'/Volumes/Data'
>>> u = toCF('Foo:').CFURLCreateWithFileSystemPath(kCFURLHFSPathStyle, False)
>>> u.CFURLCopyFileSystemPath(kCFURLPOSIXPathStyle).toPython()
u'/Foo'
Yeah, I see what you mean. You can't expect this kind of conversion
to work on a nonexistent file, and it's not one-to-one in any
case... I'd suggest just documenting it and leaving it.
--
Nicholas Riley <njriley at uiuc.edu> | <http://www.uiuc.edu/ph/www/njriley>
More information about the Pythonmac-SIG
mailing list