diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-10-02 07:48:42 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-10-02 07:48:42 +0000 |
commit | 9a46002fc01b1b874d768b2e8372b725a9e8b298 (patch) | |
tree | 9e3660449780967673d6a687f00329710e899537 /lib/find.rb | |
parent | 173e2f6636701f7657a0acb3dcba33e9d66b562d (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.rb | 35 |
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 |