Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!batcomputer!caen!sdd.hp.com!cs.utexas.edu!rice!hsdndev!dartvax!eleazar.dartmouth.edu!llama From: llama@eleazar.dartmouth.edu (Joe Francis) Newsgroups: comp.sys.mac.programmer Subject: Re: Volume Name + dirID == ? Message-ID: <1991Jun12.180730.13647@dartvax.dartmouth.edu> Date: 12 Jun 91 18:07:30 GMT References: <1991Jun11.195057.20315@ima.isc.com> Sender: news@dartvax.dartmouth.edu (The News Manager) Distribution: usa Organization: Dartmouth College, Hanover, NH Lines: 46 janee@ima.isc.com (Jane Eisenstein) writes: >I've been following the discussion on how to obtain permanent file >references. I now know how to obtain the file's volume name and >and directory ID. How do I use them to open the file? In particular, >how do I use them to open a file on an unmounted volume whose absolute >pathname is > 255 characters long? OK. The following is shortened code to do that. I'm skipping the part about mounting volumes (hiden in the imaginary function "MountViewerVolume", which also return the name of the mounted volume). If you are trying to mount AppleShare volumes, let me know and I can post on that subject. This is consensed code - no error checking, let the buyer beware: #include #include void OpenFile(StringPtr fileName, long dirID) /*open file filename in directory dirID on whatever */ /*volume MountViewerVolume mystically mounts. */ { short vRefNum,sourceRefnum = 0; Str255 sourceName; short wdRefNum; HParamBlockRec pb; MountViewerVolume((char*)(&sourceName)); /* mount volume */ SetVol((StringPtr)(&sourceName),0); /* make it current */ GetVol((StringPtr)(&sourceName),&sourceRefnum); /* get it's vol refnum */ OpenWD(sourceRefnum,dirID,0,&wdRefNum); /* make working dir */ pb.fileParam.ioCompletion = 0L; /* set up param block */ pb.fileParam.ioVRefNum = sourceRefnum; pb.fileParam.ioDirID = dirID; pb.fileParam.ioNamePtr = fileName; pb.fileParam.ioPermssn = fsCurPerm; pb.fileParam.ioMisc = 0L; PBOpen(&pb,false); /* open file */ } ---------------------------------------------------------------------------- "Read My Lips: No Nude Texans!" - George Bush clearing up a misunderstanding