[futurebasic] Re: [FB] FN folderExists%(fldrName$,inThisWDrefNum%)

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : December 1999 : Group Archive : Group : All Groups

From: Jamin <benjamen@...>
Date: Mon, 13 Dec 1999 11:26:23 +1100
Michael Evans said something like:

> FB II provides FN fileExists(fName$,fVol) which checks for the existence of
> a file named "fName$" in a folder whose WDrefNum% = fVol.
>
> To check for the existence of a folder named "fldrName$" in a folder whose
> WDrefNum% = inThisWDrefNum%, I came up with:
>
>
> Is there a faster or more sensible way of doing this not using FILES$?

How about:

CLEAR LOCAL
LOCAL FN IsFileOrFolderThere(theFileOrFolderName$, vRefNum%)
  DIM pBlock.128

  pBlock.ioCompletion& = _nil
  pBlock.ioNamePtr&    = @theFileOrFolderName$
  pBlock.ioVRefNum%    = vRefNum%
  pBlock.ioDirID&      = 0
  pBlock.ioFDirIndex%  = 0
  osErr% = FN GETCATINFO(@pBlock)

END FN = osErr%

theFileOrFolderName$ = "SubFolder:"
osErr% = FN IsFileOrFolderThere(theFileOrFolderName$, <<Your Number Here>>)
PRINT "IsFileOrFolderThere:";osErr%

OR

theFileOrFolderName$ = "HD:Folder:SubFolder:"
osErr% = FN IsFileOrFolderThere(theFileOrFolderName$, 0)
PRINT "IsFileOrFolderThere:";osErr%

Jamin