On Tue, 26 Jul 2005, Kirk Haines wrote:
> On Monday 25 July 2005 5:33 pm, Eric Hodel wrote:
>> On 25 Jul 2005, at 16:22, Kyle Heon wrote:
>>> Can anyone point me in the direction of how to walk a directory tree
>>> recursively?
>>>
>>> I'm not having much luck finding code samples via Google.
>>
>> require 'find'
>>
>> Find.find('/your/path') do |f|
>> # if you want to skip all dirs
>> next if File.directory? f
>> puts "at: #{f}"
>> end
>
> Much better than implementing it manually, but the fun thing about manually is
> that it's not that much longer. Love Ruby.
it gets alot longer if you handle links, devices, potential infinite recursion
due to directory links, and the fs changing underneath you causing errors to
be thrown as often happens in the case of gigantic or nfs fs's... speaking
from too much bad experience
btw. the find2 module on c.l.r offers a find that follows links - something
the built-in find does not do if this is important for the OP.
cheers.
-a
--
================================================== =============================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| My religion is very simple. My religion is kindness.
| --Tenzin Gyatso
================================================== =============================