Directory Walker revisited

David Vaughan dvk at dvkconsult.com.au
Wed Sep 3 19:19:01 EDT 2003


On Thursday, Sep 4, 2003, at 08:55 Australia/Brisbane, Richard Gaskin 
<ambassador at fourthworld.com> wrote:
>
> Wou you mind reposting it?  There have been so many variants here I 
> can no
> longer keep track of the proven and unproven algorithms.

Richard

here is my original posting, from 
http://lists.runrev.com/pipermail/use-revolution/2002-May/004353.html
-- 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
    put empty into tList
    set defaultFolder to dirPath
    put the long files into fList
    repeat for each line fLine in fList
      if char 1 of fLine <> "." then
        put item 1 of fLine & comma & last item of fLine into fData
        put dirPath & "/" & fData & 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

I use this on folders within the user volume and on small (few GB) 
external volumes. Search depths noted were up to about 10 in those 
cases (I added some code to display the maxDepth). I believe that total 
frame space, affected by repeat and if statements as Dar notes, will 
impose limits if you try it on a large volume including Apps and the OS 
folders.

regards
David
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 1534 bytes
Desc: not available
URL: <http://lists.runrev.com/pipermail/use-livecode/attachments/20030903/ecb1e703/attachment.bin>


More information about the use-livecode mailing list