ruby-changes:14251
From: akr <ko1@a...>
Date: Sun, 13 Dec 2009 23:51:49 +0900 (JST)
Subject: [ruby-changes:14251] Ruby:r26075 (trunk): * lib/find.rb (Find.find): sort directory entries.
akr 2009-12-13 23:48:54 +0900 (Sun, 13 Dec 2009) New Revision: 26075 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26075 Log: * lib/find.rb (Find.find): sort directory entries. [ruby-dev:39847] Modified files: trunk/ChangeLog trunk/lib/find.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 26074) +++ ChangeLog (revision 26075) @@ -1,3 +1,7 @@ +Sun Dec 13 23:48:25 2009 Tanaka Akira <akr@f...> + + * lib/find.rb (Find.find): sort directory entries. [ruby-dev:39847] + Sun Dec 13 20:55:30 2009 Tanaka Akira <akr@f...> * test/ruby/envutil.rb (invoke_ruby): call to_str for stdin_data to Index: lib/find.rb =================================================================== --- lib/find.rb (revision 26074) +++ lib/find.rb (revision 26075) @@ -46,22 +46,19 @@ 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/