[futurebasic] [FB] Re: Folder VReffin' (FB 3)

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : April 2001 : Group Archive : Group : All Groups

From: Heather Donahue <heatherd@...>
Date: Fri, 6 Apr 2001 17:46:18 -0700
At 6:49 PM +0100 on 4/6/01, Robert Covington wrote:

> >Please stop using Working Directories.
>>
> >Herbie
>
>Herbie,
>
>If you are referring to my recent post of same title, please show me an
>alternative for the below (see below). I only use what I can fathom or can
>find already done. File I/O is not a strongpoint of mine. And I couldn't
>find _any_ example of a search or listing FN that returned a VolRefnum (or
>DirID or WDR) or even a pot of gold at the end of a Rainbow, when given the
>folder's name and VolRefnum it is found in.  The "experts" responses in the
>past archives I have searched are so laser beamed in focus that extending
>things one more operation away escapes me.
>
>So given A and B, how does one properly derive C...and vice versa...
>
>A is folder name in a particular VolRefNum, B is that one knows it is a
>folder. C is the VolRefNum of the found folder, so once can go a searching
>in that one and so on.

If the runtime returned a FSSpec (file system spec) it wouldn't really be any different.  You would just pass the FSSpec to your search folder routine and plug the vRefNum and dirID in to the pBlock.

I made a Q&D change to the runtime function FILE$ to return a FSSpec and modified your code to use it.  It's not pretty but it returns the same results.  FWIW, if you use the NavServices option you get a FSSpec but the runtime doesn't pass it to you.  The other file function FN SFGetFile doesn't return a FSSpec so you need to use FN StandardGetFile

This modification could be used very easily by using a new selector like:
fileName$ = FILES$(_fspec,"",,vRefNum%)

The fileName% and vRefNum% would still be returned but a new global could be added to store the returned FSSpec.  It would require a little modification to the FILE$ runtime function but it wouldn't be very hard.

'----------------- modified SearchMyFolder
CLEAR LOCAL
LOCAL FN SearchMyFolder (pFsSpec as ^FSSpec)
DIM pbBlk.128,Filename$,Index%,OSErr%,@Type&
DIM 4 Type$ ' type and creator strings
DIM 4 Creator$

_ioBuff4 = 36

Index% = 1

_kFolderbit = 3

DO
pbBlk.ioFDirIndex%  = Index%
pbBlk.ioNamePtr&    = @Filename$
pbBlk.ioVRefNum%    = pFsSpec.vRefNum
pbBlk.ioDirID&      = pFsSpec.parID

osErr% = FN GETCATINFO (@pbBlk)
LONG IF OSErr% = _noErr
LONG IF FN BITTST (pbBlk.ioFlAttrib%,_kFolderBit )'test to see if dealing with a folder
Print
Print "Folder Found : index position ";index
Print fileName$
INC(Index%)
XELSE // a file?
Long if fileName$ <> ""
Print fileName$
End If
INC(Index%)
END IF
END IF

UNTIL OSErr% or index > 200

END FN


CLEAR LOCAL
DIM @fileName$,@vRefNum%,DirID&
Dim myFsSpec as FSSpec
LOCAL FN SearchThatFolder
fileName$ = FILES$(_fOpen,"",,vRefNum%)
myFsSpec = gStdReply.sfFile' this returns a FSSpec from the runtime
LONG IF fileName$ <> ""
FN SearchMyFolder (@myFsSpec)
END IF
END FN

-- 
Heather Donahue
--
"No one here is exactly as he appears"
			-- Ambassador G'Kar of the Narn Regime