While reading this, please keep in mind that I'm writing to target
Carbon (and maybe later, "plain old Mac Toolbox") on 9.x and earlier
systems. No MacOS X development capability here, so giving me "X-based"
advice (unless it's got an exact counterpart in Carbon) is just a waste
of time and bandwidth for both of us.
I can do a FindFolder(kOnSystemDisk, 'pref', kCreateFolder,
&FoundVRefNum, &FoundDirNum) call and locate (or, in the incredibly
unlikely event that my app is the first thing to be run after the user
has wiped out the entire Preferences folder, create) the Prefs folder,
and learn its VRefNum/DirID info. That part isn't a problem.
Once I know the VRef/DirID of the prefs folder, I can do this:
FSMakeFSSpec(FoundVRefNum, FoundDirNum, "\pMyApp Prefs", &aFileSpec)
Which accomplishes two things-
1) It tells me that "MyApp Prefs" does or does not currently exist in
the Preferences folder. (By checking the result from FSMakeFSSpec)
2) It creates the FSSpec for it, whether it exists or not.
Based on the result from FSMakeFSSpec, I'll need to do one of two
1) If "MyApp Prefs" DOES NOT exist (Result from FSMakeFSSpec == -43), I
need to create the folder. No big deal. Based on what I know right now,
I'll almost certainly do that by using a line of code similar to
"FSpDirCreate(aFileSpec, smSystemScript, &CreatedDirID)".
Assuming this call comes back with a noErr result, I've got the VRefNum
(From FindFolder) and DirID of the newly created "MyApp Prefs" folder
(stashed in CreatedDirID), and I'm golden. Everything's "kid simple"
2) If "<Startup volume>:System Folder:Preferences:MyApp Prefs" DOES
already exist, as reported by the results of MakeFSSpec() and friends,I
hit a wall - I can FSOpen(), FSDelete(), or otherwise manipulate the
folder, but so far, I haven't got a clue how to get the DirID that goes
with it so that I can operate on (determine existence/nonexistence of
one of several application settings files I need to work with,
open/read, open/write, or create/open/write them as needed by the app's
behavior, and so on) files inside it.
That's where you, the reader of this cry for help, come in...
How do I figure out the DirectoryID of *AN ALREADY EXISTING* folder
*OTHER THAN* one of the dozen or so "special" folders that FindFolder
recognizes? Getting this information for a folder that I need to create
is easy, and in fact, is given to me as a sort of "free bonus" in the
course of creating the folder. But if it already exists, I can't figure
out how to get its DirID, which is pretty well killing my ability to do
anything further with the files that are (supposed to be...) stored in
I guess I *COULD* simply scatter my files around in the Pref folder, but
I would *VERY* strongly prefer to have everything tucked neatly into a
sub-folder that lives in the Prefs folder.
Any help here?
Don Bruder - XXXX@XXXXX.COM - New Email policy in effect as of Feb. 21, 2004.
I respond to Email as quick as humanly possible. If you Email me and get no
response, see < http://www.yqcomputer.com/
form: I'm trashing EVERYTHING that doesn't contain a password in the subject.