This SHOULD be simple, but seems impossible... Help?

This SHOULD be simple, but seems impossible... Help?

Post by Don Brude » Fri, 14 May 2004 03:46:53


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
things:
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"
from here.

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
it.

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/ ~dakidd/main/contact.html> Short
form: I'm trashing EVERYTHING that doesn't contain a password in the subject.
 
 
 

This SHOULD be simple, but seems impossible... Help?

Post by Miro Juris » Fri, 14 May 2004 04:05:14

In article <xiuoc.10954$ XXXX@XXXXX.COM >,



You have the FSSpec for the folder. If you take the name in that FSSpec and
append to it ":FileName", then pass that to FSMakeFSSpec, you will get the
FSSpec for the file in the folder, which also includes the dirID of the folder.

There are also way to do this using FSGetCatalogInfo and PBGetCatInfo, but they
are more involved and you need the child FSSpec anyway.

hth

meeroh

--
If this message helped you, consider buying an item
from my wish list: < http://www.yqcomputer.com/ ;

 
 
 

This SHOULD be simple, but seems impossible... Help?

Post by Don Brude » Fri, 14 May 2004 04:42:19

In article < XXXX@XXXXX.COM >,





<"I coulda hadda V8" forehead smack, accompanied by heartfelt "D'OH!">

Why didn't I think of that? <sigh>

I was right - it *SHOULD* be simple. Because it *IS* simple - When you
get your head out of the rut that you've gotten it into while trying to
find a way to do it!


I'll take a pass on "more involved" at this point... If I get much more
"involved", I'm gonna hafta start paying alimony to this darn program!
:)

Thanks Mr. J :)

--
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/ ~dakidd/main/contact.html> Short
form: I'm trashing EVERYTHING that doesn't contain a password in the subject.