summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-03-02 02:15:21 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-03-02 02:15:21 +0000
commitaad895181ee6852c39ac68ec9c98b74f33292eed (patch)
tree4e7a621f9ab53fbea361ee4f44e50e5d1d064960 /lib
parent2bb881148493651c577d95d55a4571c36de589b6 (diff)
find.rb: add ignore_error
* lib/find.rb (Find#find): add "ignore_error" keyword argument defaulted to true. [ruby-core:51025] [Feature #7596] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45241 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/find.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/find.rb b/lib/find.rb
index 6f3e4282ed..c5fd35b1d7 100644
--- a/lib/find.rb
+++ b/lib/find.rb
@@ -34,7 +34,7 @@ module Find
#
# See the +Find+ module documentation for an example.
#
- def find(*paths) # :yield: path
+ def find(*paths, ignore_error: true) # :yield: path
block_given? or return enum_for(__method__, *paths)
fs_encoding = Encoding.find("filesystem")
@@ -48,12 +48,14 @@ module Find
begin
s = File.lstat(file)
rescue Errno::ENOENT, Errno::EACCES, Errno::ENOTDIR, Errno::ELOOP, Errno::ENAMETOOLONG
+ raise unless ignore_error
next
end
if s.directory? then
begin
fs = Dir.entries(file, encoding: enc)
rescue Errno::ENOENT, Errno::EACCES, Errno::ENOTDIR, Errno::ELOOP, Errno::ENAMETOOLONG
+ raise unless ignore_error
next
end
fs.sort!