[futurebasic] Re: [FB] usr scanfolder recursive

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : November 2008 : Group Archive : Group : All Groups

From: Robert Purves <listrp@...>
Date: Sun, 30 Nov 2008 19:16:30 +1300
Joe Lertola wrote:

> I am trying to scan a folder recursively. I am not sure why the code  
> below does not work. If I comment out the line fsr.recursive =  
> _ztrue it does work but it does not scan sub folders. Any help would  
> be appreciated

'-----------------
include "Util_Files.incl"

local fn ScanIt( fs as ^FSSpec, recursive as Boolean )
'~'1
dim as FileScanRec fsr

fsr.scanIndex = 0
fsr.recursive = recursive
do
fsr.scanSpec = fs
select usr ScanFolder( fsr )
case 0 // file
long if fsr.fndrFlags and _fInvisible
print fsr.scanIndex, "Not Visible"
xelse
print fsr.scanIndex, mki$( fsr.type ),
print fsr.dataLen,  fsr.scanSpec.name
end if
case 1 // folder
print fsr.scanIndex, mki$( fsr.type ),, fsr.scanSpec.name
if ( recursive ) then fn ScanIt( fsr.scanSpec, _zTrue )
case else // error
exit do
end select
until 0
end fn

dim as FSSpec fs
window 1,, (0, 0)-(500, 800)
long if ( files$( _FSSpecFolder, "", "", fs ) )
fn ScanIt( fs, _false )
print "-----"
fn ScanIt( fs, _zTrue )
end if
do
HandleEvents
until gFBQuit
'-----------------

Robert P.