summaryrefslogtreecommitdiffstats
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
commit77425159e2e6ba7e5bc4117a499048106541dfe3 (patch)
tree39ee539b98db696a16741c2292da77ca48eb777f
parent7f40b1581b94556db32477344ba3d9318d595019 (diff)
downloadruby-77425159e2e6ba7e5bc4117a499048106541dfe3.tar.gz
ruby-77425159e2e6ba7e5bc4117a499048106541dfe3.tar.xz
ruby-77425159e2e6ba7e5bc4117a499048106541dfe3.zip
* lib/find.rb (Find.find): sort directory entries. [ruby-dev:39847]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@26075 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--lib/find.rb29
2 files changed, 17 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index edb36542f..bb41b8bb2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Sun Dec 13 23:48:25 2009 Tanaka Akira <akr@fsij.org>
+
+ * lib/find.rb (Find.find): sort directory entries. [ruby-dev:39847]
+
Sun Dec 13 20:55:30 2009 Tanaka Akira <akr@fsij.org>
* test/ruby/envutil.rb (invoke_ruby): call to_str for stdin_data to
diff --git a/lib/find.rb b/lib/find.rb
index f9bc75415..12e2a5a93 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