On Tuesday, Sep 9, 2003, at 13:33 Europe/Brussels, [EMAIL PROTECTED] wrote:
Message: 8 Date: Tue, 9 Sep 2003 17:34:09 +1000 Subject: Re: Deep Space (was: The Directory Walker revisited) From: David Vaughan <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED]
snip
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.
regards David
Hi, If this post is redundant don't read it. My workaround "OS X only":
on mouseUp 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" end mouseUp
-- 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
put dirPath
-- 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
return empty
end if
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 after tList
end repeat
#### 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
end if
end repeat
repeat for each line l in tList2Delete
delete line lineoffset(l,it) of it
end repeat
*/
repeat for each line x in it
put walkDir(dirPath & x) after tList
end repeat
-- subtract 1 from isDepth
return tList
end walkDirGreetings WA
_______________________________________________ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution
