Newsgroups: comp.sys.mac.programmer
Path: utzoo!utgpu!topix
From: topix@gpu.utcs.utoronto.ca (R. Munroe)
Subject: More Vol RefNum + WD ID Help Needed
Message-ID: <1991Jun9.062859.3306@gpu.utcs.utoronto.ca>
Organization: UTCS Public Access
Date: Sun, 9 Jun 1991 06:28:59 GMT

By now I feel fairly brain dead.  I got lots of help when I posted
my last message about saving file info into a prefs file so I could
open the files from a menu in my app.  Most replies said to save
the volume name, working directory ID, and file name.  I think that
I have successfully done that.  I now am trying to use that info to
open up the file.  No luck.  Here is the code I use to store the info:

    WDPBRec    wdpb;

    if (reply.good)
    {
        wdpb.ioCompletion = NIL_POINTER;
        wdpb.ioNamePtr = (StringPtr)name; /* just used as a place holder */
        wdpb.ioVRefNum = reply.vRefNum;
        wdpb.ioWDIndex = 0;
        wdpb.ioWDDirID = 0;
				
        error = PBGetWDInfo (&wdpb, FALSE);
	
        /* ..... save wdpb.ioNamePtr, wdpb.ioWDDirID, and reply.fName
                 into prefs file ..... */
    }	

And here is what I'm doing to open my stored working directory ID:

    WDPBRec    wdpb;
    HFileInfo  pb;

    {
        /* ..... read wdpb.ioNamePtr (volumeName), wdpb.ioWDDirID (wdID),
                 and reply.fName (fileName) from prefs file ..... */

        wdpb.ioCompletion = NIL_POINTER;
        wdpb.ioNamePtr = (StringPtr)volumeName;
        wdpb.ioWDDirID = wdID;

        error = PBOpenWD (&wdpb, FALSE);

        pb.ioNamePtr = (StringPtr)fileName;
        pb.ioVRefNum = wdpb.ioVRefNum;
        pb.ioFDirIndex = 0;
        pb.ioDirID = 0;

        error = PBGetFInfo (&pb, FALSE);
    }

PBOpenWD always returns fnfErr (file not found).  What am I doing
wrong?  If I print out my variables, I find that, sure enough, my
volume name, working directory ID, and file name are just as I had
stored them - so I don't think the problem is with that.

I've been struggling with this for two straight days and have tried 
countless combinations and permutations of low-level File Manager
calls.  Any help would be most^32 appreciated.

Bob Munroe
topix@utcs.utoronto.ca

