wouter.abraham at pi.be
Wed Sep 10 00:25:00 CDT 2003
On Tuesday, Sep 9, 2003, at 13:33 Europe/Brussels,
use-revolution-request at lists.runrev.com wrote:
> Message: 8
> Date: Tue, 9 Sep 2003 17:34:09 +1000
> Subject: Re: Deep Space (was: The Directory Walker revisited)
> From: David Vaughan <dvk at dvkconsult.com.au>
> To: use-revolution at lists.runrev.com
> Reply-To: use-revolution at lists.runrev.com
> Found it folks!
> On OS X systems the folder //Network contains a reference to the local
> computer, which is where you started, so round you go again.
> I made a specific adjustment at the beginning of the handler, thus:
> function walkDir dirPath
> if dirPath contains "//Network" then
> return empty
> end if
> -- etc as before
> Running this worked across the entire root volume, returning over
> 230,000 files in a 24MB list (maxDepth 18 as expected), no problems.
> The same circularity will equally affect an iterative routine, not only
> a recursive approach, so whatever you do you need to protect against
> the specific problem or simply not allow a user to walk from root. The
> point of this exercise was to confirm that stack size did not limit a
> recursive approach.
> Note also WA's apparent problem with an X11 sub-folder, although
> aliases did not appear to have added any circularity in my testing. Any
> routine should also be tested specifically on a Linux or Windows
> platform if it will be deployed there. The testing code comprises
> displaying the current path every time you hit a new maxDepth.
If this post is redundant don't read it.
My workaround "OS X only":
put empty into field "result"
answer folder "Pick a folder you want to walk:"
if it is empty then exit mouseUp
if last char of it <> "/" then put "/" after it
put walkDir(it) into field "result"
-- 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
#### could take a long time so to give something to read meantime
-- add 1 to isDepth
-- if isDepth > limitDepth then
-- put isDepth into limitDepth
-- put limitDepth
-- 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
-- subtract 1 from isDepth
put the long files into fList
put dirPath & return after tList
### to eliminate invisible files
filter fList with "[!.]*"
repeat for each line fLine in fList
put dirPath & item 1 of fLine & comma & last item of fLine & return
#### change to eliminate the aliases
get shell("ls -F")
filter it with "*[/]"
#### decoment to eliminate
#### apps folder investigation
repeat for each line l in it
set the directory to dirPath &l&"/"&"Contents"
put the folders into a
if "MacOS" is in a and "Resources" is in a then
--put dirPath &"/"&l & return after tList
put dirPath & l & return after tList
put l &cr after tList2Delete
repeat for each line l in tList2Delete
delete line lineoffset(l,it) of it
repeat for each line x in it
put walkDir(dirPath & x) after tList
-- subtract 1 from isDepth
More information about the use-livecode