aboutsummaryrefslogtreecommitdiffstats
path: root/lib/find.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-12-13 14:48:54 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-12-13 14:48:54 +0000
commitc48a4c293650efe407049e6aceed53fcd35a741b (patch)
tree39ee539b98db696a16741c2292da77ca48eb777f /lib/find.rb
parentf62310ac626f8fd729a066ba5f31619bf3d15f56 (diff)
downloadruby-c48a4c293650efe407049e6aceed53fcd35a741b.tar.gz
* lib/find.rb (Find.find): sort directory entries. [ruby-dev:39847]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26075 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/find.rb')
-rw-r--r--lib/find.rb29
1 files changed, 13 insertions, 16 deletions
diff --git a/lib/find.rb b/lib/find.rb
index f9bc754152..12e2a5a938 100644
--- a/lib/find.rb
+++ b/lib/find.rb
@@ -46,22 +46,19 @@ module Find
end
begin
if s.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
- paths.unshift f.untaint
- end
- ensure
- d.close
- end
+ fs = Dir.entries(file)
+ fs.sort!
+ fs.reverse_each {|f|
+ 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
+ paths.unshift f.untaint
+ }
end
rescue Errno::ENOENT, Errno::EACCES
end