[REBOL] Re: Reading directories faster.
From: greggirwin:mindspring at: 8-Oct-2002 14:27
Hi Alan,
<<
I am using the code below to read and sort the current directory contents.
It is _terribly_ slow on large directories (> 1000 files/directories)
either none? df: attempt [read %./][
"Error reading Directory"
][
foreach file df [insert tail either (dir? file)[dirs][files] file]
]
>>
DIR? does a bit of work to find out if a file has the directory flag set for
it (look at the source for it). Since REBOL is very consistent about how it
forms directory names, you can cheat a bit and avoid the extra disk hits for
every file by doing something like this:
either none? df: attempt [read %.][
"Error reading Directory"
][
foreach file df [
insert tail either (#"/" = last file)[dirs][files] file
]
]
--Gregg