lbaum@bcsaic.UUCP (Larry Baum) (06/28/90)
I am trying to get the following code, downloaded from apple.com (Mac
DTS Sample Code #18). It is a file filter for SFGetFile so that only
files with ALRT resources are shown.
This code is for MPW C and I am using Think C.
When I tried this, I first encouneter a bus error at:
oldResLoad = *(Boolean *)ResLoad;
I changed that to:
oldResLoad = ResLoad;
The trouble is that
PBOpenWD(&WDRec,false);
consistently fails with resErr = -35.
p->fileParam.ioVRefNum is always -1.
Any ideas what is wrong?
Larry Baum
Advanced Technology Center
Boeing Computer Services uucp: uw-beaver!bcsaic!lbaum
(206) 865-3365 internet: lbaum@atc.boeing.com
------------------------------< cut here >--------------------
pascal Boolean ComplexFileFilter(p)
ParmBlkPtr p;
{
short refnum, tRefNum;
WDPBRec WDRec;
ParamBlockRec oldVol, newVol;
Boolean oldResLoad, closeIt;
Handle tHandle;
Boolean returnVal;
returnVal = true; /* Don't show it -- default */
/* Save the current setting of ResLoad. Then set it to FALSE. */
oldResLoad = *(Boolean *)ResLoad;
SetResLoad(false);
/* Save the current default directory/volume. */
oldVol.volumeParam.ioNamePtr = nil;
PBGetVol(&oldVol,false);
/* Create a working directory for the directory we are examining. */
WDRec.ioNamePtr = nil;
WDRec.ioVRefNum = p->fileParam.ioVRefNum;
WDRec.ioWDProcID = 'ERIK';
WDRec.ioWDDirID = *(long *)CurDirStore;
PBOpenWD(&WDRec,false);
/* Set the Working Directory we just created to be the default. */
newVol.volumeParam.ioNamePtr = nil;
newVol.volumeParam.ioVRefNum = WDRec.ioVRefNum;
PBSetVol(&newVol,false);
/* Check the current value of TopMapHndl, open the resource file, and */
/* check it again. If it changed, then note that we should close this */
/* file later when we are done with it. */
tHandle = *(Handle *)TopMapHndl;
refnum = OpenResFile(p->fileParam.ioNamePtr);
if (tHandle != *(Handle *)TopMapHndl)
closeIt = true;
else
closeIt = false;
/* If we successfully opened the file, then count the number of ALRT */
/* resources in it. Call UseResFile to make sure that the file we just */
/* 'opened' is the current one. We have to do this, as OpenResFile will */
/* not make the file the current one if it is already open. So save the */
/* current resFile, (possibly) change it to the one we want, read the */
/* number of ALRT resources in it, and then set the current resource */
/* file back to what it was. Finally, if we need to close the file we */
/* opened, do so. */
if (ResError() == noErr) {
tRefNum = CurResFile();
UseResFile(refnum);
if (Count1Resources('ALRT') > 0) returnVal = false;
UseResFile(tRefNum);
if (closeIt) CloseResFile(refnum);
};
/* All done! Reset the default directory and ResLoad, and then blow. */
PBSetVol(&oldVol,false);
PBCloseWD(&WDRec,false);
SetResLoad(oldResLoad);
return(returnVal);
};
--
Larry Baum
Advanced Technology Center
Boeing Computer Services uucp: uw-beaver!bcsaic!lbaum
(206) 865-3365 internet: lbaum@atc.boeing.com russotto@eng.umd.edu (Matthew T. Russotto) (06/28/90)
In article <27161@bcsaic.UUCP> lbaum@bcsaic.UUCP (Larry Baum) writes: > >I am trying to get the following code, downloaded from apple.com (Mac >DTS Sample Code #18). It is a file filter for SFGetFile so that only >files with ALRT resources are shown. > >This code is for MPW C and I am using Think C. > >When I tried this, I first encouneter a bus error at: > > oldResLoad = *(Boolean *)ResLoad; > >I changed that to: > > oldResLoad = ResLoad; > If you caught this one, you are going to kick yourself for not catching the next one :-) >The trouble is that > > PBOpenWD(&WDRec,false); > >consistently fails with resErr = -35. Not resErr. ioErr. > WDRec.ioWDDirID = *(long *)CurDirStore; > > PBOpenWD(&WDRec,false); Try WDRec.ioWDDirID = CurDirStore -- Matthew T. Russotto russotto@eng.umd.edu russotto@wam.umd.edu ][, ][+, ///, ///+, //e, //c, IIGS, //c+ --- Any questions?