[comp.sys.mac.programmer] How to open Res file given Volume Ref Num and DirID

gft_robert@gsbacd.uchicago.edu (05/09/90)

Thanks to all those who informed me that -1 is in fact the boot volRefNum.  Ah
well, we all get to act dumb sometimes, and I guess it was my turn. :->

I have another problem: I need to open the resource fork of a file given a
volume ref num and a dir id (I'm trying to open default files, and I store the
volume name and the dir id's of these files in a 'pref file').

Seems simple enough: just PBHSetVol() and then OpenResFile().  But no: TN 177
(I think that's the number) says that PBHSetVol() is not a good call to make,
since it can screw up GetVol later on.

So how does one do it?  Open a WD with PBOpenWD() and pass that to SetVol()? 
That is simple enough, but I think I read in another TN that one should in
general not open WD's onesself, and one should close them ASAP.  Or is this one
of those special cases where the ends justify the means?  I don't want this app
breaking with future systems after I'm gone from this client, though.

I've heard that MPW has the call HOpenResFile() in its libraries, but I'm using
THINK Pascal.  When I get home I'll check the manuals to see if there's an
equivalent.  I guess I could compile it as a unit under MPW, and then link it
in.

Any info much appreciated!

Robert



 
============================================================================
= gft_robert@gsbacd.uchicago.edu * generic disclaimer: * "It's more fun to =
=            		         * all my opinions are *  compute"         =
=                                * mine                *  -Kraftwerk       =
============================================================================