On Apr 24, 11:21 am, "Leslie Viljoen" <leslievilj... / gmail.com> wrote:
> On 4/24/07, Daniel Berger <djber... / gmail.com> wrote:
>
>
>
> > Hi all,
>
> > I'm happy to announce the first release of file-find. This package is
> > meant as a replacement for the current 'find' module in the Ruby
> > standard library. It provides many more options for controlling the
> > behavior of your find operations.
>
> > It is modelled on the 'find' command typically found on Unix systems.
>
> > Example1:
>
> > # Look for all .rb files changed in the last 24 hours
> > rule = File::Find.new(:name => "*.rb", :ctime => 0)
> > rule.find{ |file| puts file }
>
> > # Look for all text files owned by user id 23, don't follow symlinks
> > rule = File::Find.new(:name => "*.txt", :user => 23, :follow => false)
> > rule.find{ |file| puts file }
>
> > You can find install the file-find package as a gem, or grab the file
> > from the project page athttp://rubyforge.org/projects/shards/. You
> > can also find it on the RAA.
>
> Woo! Thanks!
> One question: what happens when you iterate over a directory you do
> not have permission to read?Riothrows an exception and exits,
> meaning the remaining files are skipped, which is not cool.

Rio does raise an exception when trying to read the contents of a
directory that one does not have permission to read. This behaviour is
due to the fact that Rio is a facade for the builtin class Dir -- and
Dir raises an exception. Personally I think this behavior is
appropriate. Silently skipping unreadable directories is not always
desired

> I tried to
> provide an option to skip forbidden directories, but Rio is a bit
> convoluted.

No additional option is required to get the desired behavior. Rio
allows control of which directories will be recursed into.

rio('adir').recurse(:readable?).files('*.txt') { ... }

This will silently skip unreadable directories.

-Christopher