summaryrefslogtreecommitdiff
path: root/lib/find.rb
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-10-02 07:48:42 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-10-02 07:48:42 +0000
commit9a46002fc01b1b874d768b2e8372b725a9e8b298 (patch)
tree9e3660449780967673d6a687f00329710e899537 /lib/find.rb
parent173e2f6636701f7657a0acb3dcba33e9d66b562d (diff)
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@985 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/find.rb')
-rw-r--r--lib/find.rb35
1 files changed, 19 insertions, 16 deletions
diff --git a/lib/find.rb b/lib/find.rb
index e79756a918..80bb5d6f59 100644
--- a/lib/find.rb
+++ b/lib/find.rb
@@ -10,27 +10,30 @@
module Find
def find(*path)
while file = path.shift
- catch(:prune) {
+ catch(:prune) do
yield file
- if File.lstat(file).directory? then
- d = Dir.open(file)
- begin
- for f in d
- next if f == "." or f == ".."
- if File::ALT_SEPARATOR and file =~ /^(?:[\/\\]|[A-Za-z]:[\/\\]?)$/ then
- f = file + f
- elsif file == "/" then
- f = "/" + f
- else
- f = File.join(file, f)
+ begin
+ if File.lstat(file).directory? then
+ d = Dir.open(file)
+ begin
+ for f in d
+ next if f == "." or f == ".."
+ if File::ALT_SEPARATOR and file =~ /^(?:[\/\\]|[A-Za-z]:[\/\\]?)$/ then
+ f = file + f
+ elsif file == "/" then
+ f = "/" + f
+ else
+ f = File.join(file, f)
+ end
+ path.unshift f
end
- path.unshift f
+ ensure
+ d.close
end
- ensure
- d.close
end
+ rescue Errno::ENOENT
end
- }
+ end
end
end