Directory Walker Conundrum
David Vaughan
dvk at dvkconsult.com.au
Sun May 28 20:06:48 EDT 2006
On 29/05/2006, at 9:52, Alex Tweedly wrote:
>
> change
> delete line 1 of tDirList
> to something like
> filter tDirList without ".."
This one works anyway, and also does not suffer from a couple of
other bugs which exist in Ken's older version, to do with permissions
and infinite recursion in OS X and possibly other 'nixes.
-- This recursive function expects a folder path.
-- It returns a file list for that folder and for each
-- sub-folder it contains (pre-order search)
-- Invisible files are excluded.
function walkDir dirPath
if dirPath contains "//Network" then
return empty
end if
put empty into tList
set defaultFolder to dirPath
-- Dar's discovery. Check permissions were ok
get the Result
if it is not empty then
return empty
end if
put the long files into fList
repeat for each line fLine in fList
if char 1 of fLine <> "." then
-- Change this line to determine what components are returned
put dirPath & "/" & item 1 of fLine & comma & item -2 to -1 of
fLine & return after tList
end if
end repeat
get the folders
repeat for each line x in it
if char 1 of x <> "." then
put walkDir(dirPath & "/" & x) after tList
end if
end repeat
return tList
end walkDir
regards
David
More information about the use-livecode
mailing list