Michael Evans wrote: > Small issue: Rick supplied: > > "itsAnAlias = (gPBlk.ioFlUsrWds.fdFlags% AND BIT(15)) <> 0)" > > which was missing a parenthesis and should have been writen: > > itsAnAlias = ((gPBlk.ioFlUsrWds.fdFlags% AND BIT(15)) <> 0) Hey, I've been using too many left parenetheses lately, and I was just trying to cut down! :-) > '----------------------------------------- > CLEAR LOCAL > LOCAL FN getTheDataForkFileSize%(myFileName$,mySrcWDrefNum%) > '----------------------------------------- > DIM filePath$, theFileSize&, theKBs%, temp! > DIM ParamBlock.128 > DIM ioErr% > > filePath$ = FN convertWDRef$(myFileName$,mySrcWDrefNum%) > ParamBlock.ioNamePtr& = @filePath$ > ParamBlock.ioFDirIndex& = 0 > ioErr% = FN GETFILEINFO (@ParamBlock) > LONG IF ioErr% = 0 > theFileSize& = ParamBlock.ioFlPyLen& > END IF > > temp! = theFileSize&/1024 > theKBs% = INT(temp!) > END FN = theKBs% > > > which I use before "OPEN"ing a file. > > This routine relies on a filepath. How can I rewite it to either > > 1) rely on FileName$ and FileWDrefNum% > > or > > 2) [preferably] rely on a FSSpec derived from an Alias. HGETFILEINFO (the HFS version of GETFILEINFO) is really robust. Here's a slight variation on your routine that will allow to specify the file in a _variety_ of different ways: '----------------------------------------- CLEAR LOCAL LOCAL FN getTheDataForkFileSize%(theFile$, vRefNum%, dirID&) '----------------------------------------- DIM theFileSize&, theKBs%, temp! DIM ParamBlock.128 DIM ioErr% ParamBlock.ioCompletion& = _nil ParamBlock.ioNamePtr& = @theFile$ ParamBlock.ioVRefNum% = vRefNum% ParamBlock.ioDirID& = dirID& ParamBlock.ioFDirIndex& = 0 ioErr% = FN HGETFILEINFO (@ParamBlock) LONG IF ioErr% = 0 theFileSize& = ParamBlock.ioFlPyLen& END IF temp! = theFileSize&/1024 theKBs% = INT(temp!) END FN = theKBs% '------------------------------------------- Here's how to call this routine: * If you have a complete path name for the file, then specify it in theFile$. The vRefNum% and dirID& parameters are ignored in this case. * If you have a file name and a working directory ref. number, then pass them in theFile$ and vRefNum%, and pass 0 in dirID&. * If you have a file name, a volume reference number and a directory ID number (as in the components of an FSSpec record), then pass them in theFile$, vRefNum% and dirID&, respectively. If what you're really interested in using is an FSSpec record, then here's a very minor modification that will work: '----------------------------------------- DIM RECORD fsSpecRec DIM fsVRefNum% DIM fsParID& DIM 63 fsName$ DIM END RECORD .fsSpecRec '----------------------------------------- CLEAR LOCAL LOCAL FN getTheDataForkFileSize%(fsSpecPtr&) 'Call as follows: ' theKBs% = FN getTheDataForkFileSize%(@myFSSpec) 'where "@myFSSpec" is the pointer to a 70-byte FSSpec record. '----------------------------------------- DIM theFileSize&, theKBs%, temp! DIM ParamBlock.128 DIM ioErr% ParamBlock.ioCompletion& = _nil ParamBlock.ioNamePtr& = @fsSpecPtr&.fsName$ ParamBlock.ioVRefNum% = fsSpecPtr&.fsVRefNum% ParamBlock.ioDirID& = fsSpecPtr&.fsParID& ParamBlock.ioFDirIndex& = 0 ioErr% = FN HGETFILEINFO (@ParamBlock) LONG IF ioErr% = 0 theFileSize& = ParamBlock.ioFlPyLen& END IF temp! = theFileSize&/1024 theKBs% = INT(temp!) END FN = theKBs% Hope this helps. - Rick