ruby-changes:19084
From: nobu <ko1@a...>
Date: Fri, 18 Mar 2011 08:48:20 +0900 (JST)
Subject: [ruby-changes:19084] Ruby:r31123 (trunk): * lib/fileutils.rb (FileUtils::Entry_#copy_file): updated FileUtils.cp
nobu 2011-03-18 08:48:13 +0900 (Fri, 18 Mar 2011) New Revision: 31123 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=31123 Log: * lib/fileutils.rb (FileUtils::Entry_#copy_file): updated FileUtils.cp to still copy file permissions when :preserve is false (as cp does this even when -p isn't set). Modified files: trunk/ChangeLog trunk/lib/fileutils.rb trunk/test/fileutils/test_fileutils.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 31122) +++ ChangeLog (revision 31123) @@ -1,3 +1,9 @@ +Fri Mar 18 08:48:06 2011 Oleg Shaldybin <oleg.shaldybin@g...> + + * lib/fileutils.rb (FileUtils::Entry_#copy_file): updated FileUtils.cp + to still copy file permissions when :preserve is false (as cp does + this even when -p isn't set). + Fri Mar 18 00:59:38 2011 Nobuyoshi Nakada <nobu@r...> * ext/win32ole/extconf.rb (create_docfile): removed. should not Index: lib/fileutils.rb =================================================================== --- lib/fileutils.rb (revision 31122) +++ lib/fileutils.rb (revision 31123) @@ -1276,7 +1276,7 @@ def copy_file(dest) File.open(path()) do |s| - File.open(dest, 'wb') do |f| + File.open(dest, 'wb', s.stat.mode) do |f| IO.copy_stream(s, f) end end Index: test/fileutils/test_fileutils.rb =================================================================== --- test/fileutils/test_fileutils.rb (revision 31122) +++ test/fileutils/test_fileutils.rb (revision 31123) @@ -230,6 +230,16 @@ } end + def test_cp_preserve_permissions + bug4507 = '[ruby-core:35518]' + touch 'tmp/cptmp' + chmod 0755, 'tmp/cptmp' + cp 'tmp/cptmp', 'tmp/cptmp2' + assert_equal(File.stat('tmp/cptmp').mode, + File.stat('tmp/cptmp2').mode, + bug4507) + end + def test_cp_symlink touch 'tmp/cptmp' # src==dest (2) symlink and its target -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/