[comp.sys.mac.programmer] Lost in HFS

LIPA@POLYA.STANFORD.EDU (William J. Lipa) (04/04/88)

What is the best way to find out the wdRefNum or directoryId of the current
application's directory under HFS? The default volume seems to be the root
directory of the application's disk, not the application's own directory.

Thanks,

Bill Lipa

alternates: lipa%polya%forsythe.stanford.edu  lipa%polya%forsythe.bitnet
-------

jv0l+@andrew.cmu.edu (Justin Chris Vallon) (04/06/88)

To get information about the default volume/wdRefNum/dirId, you should use
PBHGetVol.  Depending upon what you want, look at different fields:

    ioVRefNum
        This field returns the volRefNum of the default volume.  According to
        IM IV-132: "IOVRefNum will return a working directory reference number
        (instead of the volume reference number) if, in the last call to
        PBSetVol or PBHSetVol, a wd ref num was passed in this field."  This
        means that if the last call to PBHSetVol used a volRefNum/dirId pair,
        you will get the volRefNum;  if it created a wd and passed it, then
        the wd will be returned.

    ioWDVRefNum
        This is always the volume reference number (never wd ref num) of the
        default volume

    ioWDDirID
        This is the dirId of the default volume (2 if root)

As far as I can remember, the Finder sets up everything so that a PBGetVol/
PBHGetVol call will return the wdVolRefNum of the application in ioVRefNum.

Above, I used the "low-level" calls, but the "high-level" call
GetVol(name, &vrn) should also work.

-Justin
justin.vallon@andrew.cmu.edu