summaryrefslogtreecommitdiff
path: root/lib/find.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/find.rb')
-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!