On Fri, 13 May 2005, Nakada, Nobuyoshi wrote:

> Hi,
>
> At Fri, 13 May 2005 00:45:27 +0900,
> Ara.T.Howard / noaa.gov wrote in [ruby-talk:142400]:
>> from the find2 code i've incorporated into my personal lib (Alib):
>>
>>    #
>>    # If `entry_path' is a directory, find recursively.
>>    #
>>    if stat_result.directory? \
>>      && (!@xdev || @xdev_device == stat_result.dev) \
>>      && (!@follow || !visited?(stat_result))
>
> This "visited?" method would be the key.  We know it is possible, but
> judged it is too expensive to implement as built-in.

it doesn't look too bad in these dirs - which are quite big:

   gilligan:/ftp/cfd0-0/avg_dn > time ruby -r find -e 'a = [];Find::find(Dir::pwd){|f| a << f};p a.size'

   35288

   real    0m0.731s
   user    0m0.490s
   sys     0m0.240s


   gilligan:/ftp/cfd0-0/avg_dn > time ruby -r find2 -e 'a = [];Find2::find(Dir::pwd,:follow=>true){|f| a << f};p a.size'

   35286

   real    0m0.990s
   user    0m0.760s
   sys     0m0.200s


also note that following links is an option.

my problem with the builtin Find module and Dir[] is that our site has tons of
disks and so have to organize them logically: eg

   ...
   /mnt/raid/0/1/2
   /mnt/raid/0/1/3
   ...
   /mnt/raid/0/2/0
   ...

etc.  this is pretty ugly to deal with so we also setup functional and
hierarchical structures via symlink to we can remember what all the stuff is:

   /dmsp/rico/ftp -> /dmsp/ftp/rico
   /dmsp/rico/www -> /dmsp/www/rico

   /dmsp/ftp -> /mnt/raid/0/1/2/
   /dmsp/www -> /mnt/raid/0/1/3/

and ruby then becomes useless for doing find type operations in this
environment since any view of the fs stops dead at a link.  in any case, i
certainly can (have) dealt with it by using Find2 - is there any reason this
module, or something similar, shouldn't be included in the core?

kind regards.

-a
-- 
===============================================================================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| renunciation is not getting rid of the things of this world, but accepting
| that they pass away. --aitken roshi
===============================================================================