Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!rex!ames!ads.com!jtn From: jtn@ADS.COM (John T. Nelson) Newsgroups: comp.sys.mac.programmer Subject: Problems with PBGetCat and other related things (LONG) Message-ID: <$$B&70=@ads.com> Date: 3 Mar 91 19:35:49 GMT Sender: usenet@ads.com (USENET News) Organization: Advanced Decision Systems, Mtn. View, CA (415) 960-7300 Lines: 90 Grak! I'm having problems with PBGetCat and PBGetFInfo. I suspect the problem is because I am not positioned in the correct directory but it's difficult to tell where the problem is. I have a subroutine called directoryP() which tries to test for a directory in the current working directory which I previously set using SetVol() in my function GoToDirectory(). Here's the problem. A call to PBGetFInfo ALWAYS returns -43 which is fnfErr in Mac error results lore. The folder/file I test for is located by SFPGetFile although it is in the same directory that the program is run from. I also have an identical folder located at the root-most directory (because I suspected my working directory wasn't really where I thought it was) and yet it still fails. I set my directories by getting the (long) directory ID of the directory in which to search and then using PBopenWD to get a refNum I can then use with SetVol. Now the funny thing here is that I'm emulating the code that is used in the Unshar utility recently distributed on the net. This utility passes a (long) into SetVol which I think is wrong. SetVol takes an int... not a long. The long dirID passed into GoToDirectory() is derived from the global CurDirSave after doing an SFPGetFile. Here's the code fragment that does that: if (reply.good) { dirVRefNum = reply.vRefNum; if (useCurDir) { dirDirID = CurDirStore; } else { dirDirID = (long)(reply.fType); } } return(dirDirID); GoToDirectory(long dirID) { long dID; /* short dID; */ /* int dID */ wdpb.ioCompletion = NIL; wdpb.ioNamePtr = NIL; wdpb.ioVRefNum = dirVRefNum; wdpb.ioWDDirID = dirID; if (PBOpenWD(&wdpb, FALSE) != noErr) { return; } dID = dirVRefNum = wdpb.ioVRefNum; (void)SetVol(NIL, dID); } Boolean directoryP(Str255 file) { Str255 vName; int vRefNum; CInfoPBRec cBlock; OSErr err; cBlock.dirInfo.ioCompletion = NIL; cBlock.dirInfo.ioNamePtr = file; GetVol(&vName, &vRefNum); /*cBlock.dirInfo.ioVRefNum = - ( *(short *) SFSaveDisk );*/ cBlock.dirInfo.ioVRefNum = vRefNum; cBlock.dirInfo.ioFDirIndex = 0; err = PBGetFInfo(&cBlock, SYNCHRONOUS); if ( err == fnfErr ) return FALSE; if ( cBlock.dirInfo.ioFlAttrib & 0x010 ) return TRUE; else return FALSE; } Any ideas on what I'm doing wrong? =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ORGANIZATION: Advanced Decision Systems GEOGRAPHIC: Arlington, VA UUCP: kzin!speaker@mimsy.umd.edu INTERNET: jtn@potomac.ads.com SPOKEN: Dark Hacker PHONE: (703) 243-1611 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=