Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!lll-winken!uunet!zephyr.ens.tek.com!gvgpsa!treehouse!andyp From: andyp@treehouse.UUCP (Andy Peterman) Newsgroups: comp.sys.mac.programmer Subject: Re: More Vol RefNum + WD ID Help Needed Message-ID: <911@treehouse.UUCP> Date: 9 Jun 91 18:30:53 GMT References: <1991Jun9.062859.3306@gpu.utcs.utoronto.ca> Organization: The Treehouse Lines: 59 In article <1991Jun9.062859.3306@gpu.utcs.utoronto.ca> topix@gpu.utcs.utoronto.ca (R. Munroe) writes: >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. Why do you need to open a WD? Apple has been trying to get people to stop using working directories and you can probably get by without them. First, get the volumeRefNum: pb.ioNamePtr = (StringPtr)volumeName; pb.ioVRefNum = 0; pb.ioVolIndex = -1; error = PBGetVolInfo (&pb, FALSE); This returns ioVRefNum, along with a bunch of other information (to be sure you have the correct volume, you could have also saved the creation date of the volume and check it at this time). Now, to access the file, use any of the PBH calls, for example: pb.ioNamePtr = (StringPtr)fileName; pb.ioVRefNum = volumeRefNum; // Leave out if same pb from last call pb.ioFDirIndex = 0; pb.ioDirID = wdID; error = PBHGetFInfo (&pb, FALSE); Note that as long as you call the File Manager routines synchronously (with the second parameter FALSE), you do not need to clear ioCompletion - the trap dispatcher does that for you. -- Andy Peterman | Everything you know treehouse!andyp@gvgpsa.gvg.tek.com | is wrong! (916) 273-4569 | FST