[Pythonmac-SIG] Using Carbon for files; a brief intro

Jack Jansen Jack.Jansen at cwi.nl
Thu Feb 5 17:29:32 EST 2004


On 4-feb-04, at 19:44, Russell E. Owen wrote:

> I just had to figure out how to use Carbon to obtain the preferences
> folder and thought I'd share what I learned. I hope to find time to put
> some of this into the Carbon docs someday, but right now time is short.
>
> The first step is to look at Apple's docs, as the MacOS Toolbox docs
> say: <http://developer.apple.com/documentation/macos8/mac8.html>
>
> The important modules are as follows. Note that only the last of these
> is listed in the Python manual. I ended up finding these by searching
> through the source code looking for constants I needed. The lesson: if
> you are going to use Carbon, print dir(Carbon) and also have the source
> around so you can search it. But I digress...the important modules for
> files and folders are:
> - Carbon.File: File Manager routines
> - Carbon.Files: constants for File Manager routines
> - Carbon.Folder: Folder Manager routines
> - Carbon.Folders: constants for Folder Manager routines

They should at least be listed in the documentation, along with all the 
other Carbon modules. If they really aren't: please file a bug report. 
Make it a documentation bug report, but assign it to me.

> Also note that FSSpec objects have methods that implement some of the
> File Manager routines (very nice). There is an alternate means of
> referring to files, FSRref objects, which do not have any methods. I am
> not sure the tradeoffs for using one or the other. I ended up using
> FSSpec objects.

Why do you think FSRef objects don't have any methods? They have quite 
a few...

Also, in the code you actually use FSRefs (FSFindFolder() returns an 
FSRef)....
FSRefs are newer than FSSpecs, and are deemed to be the wave of the 
future. FSSpecs have one advantage, though: they can refer to 
non-existing files, which FSRefs can't.
--
Jack Jansen, <Jack.Jansen at cwi.nl>, http://www.cwi.nl/~jack
If I can't dance I don't want to be part of your revolution -- Emma 
Goldman




More information about the Pythonmac-SIG mailing list