how to resume Find.find after a failure?

P

Paul Brannan

If a file is unreadable on Linux, Find.find seems to skip it and move to
the next file.

However, if a file is unreadable on Windows, Find.find seems to raise an
exception, and I see no way to go to the next file:

C:\temp>ruby -e 'puts RUBY_VERSION'
1.8.1

C:\temp>mkdir foo bar baz

C:\temp>echo > bar\file1.txt

C:\temp>echo > baz\file2.txt

C:\temp>echo > foo\file3.txt

C:\temp>ruby -rfind -e "Find.find('.') { |f| p f }"
"."
"./foo"
"./foo/file3.txt"
"./baz"
"./baz/file2.txt"
"./bar"
"./bar/file1.txt"

(now I remove the read privilege from the baz directory using Windows
Explorer)

C:\temp>ruby -rfind -e "Find.find('.') { |f| p f }"
"."
"./foo"
"./foo/file3.txt"
"./baz"
c:/ruby/lib/ruby/1.8/find.rb:42:in `open': Invalid argument - ./baz (Errno::EINVAL)
from c:/ruby/lib/ruby/1.8/find.rb:42:in `find'
from c:/ruby/lib/ruby/1.8/find.rb:38:in `catch'
from c:/ruby/lib/ruby/1.8/find.rb:38:in `find'
from -e:1

Is this a bug? Is there a workaround?

Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top