ruby-changes:13075
From: nobu <ko1@a...>
Date: Wed, 9 Sep 2009 22:02:21 +0900 (JST)
Subject: [ruby-changes:13075] Ruby:r24823 (trunk): * lib/fileutils.rb (FileUtils::Entry_#copy_file): open the source
nobu 2009-09-09 22:02:04 +0900 (Wed, 09 Sep 2009) New Revision: 24823 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=24823 Log: * lib/fileutils.rb (FileUtils::Entry_#copy_file): open the source file first to ensure it can be copied. [ruby-core:25498] Modified files: trunk/ChangeLog trunk/lib/fileutils.rb trunk/test/fileutils/test_fileutils.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 24822) +++ ChangeLog (revision 24823) @@ -1,3 +1,8 @@ +Wed Sep 9 22:02:02 2009 Nobuyoshi Nakada <nobu@r...> + + * lib/fileutils.rb (FileUtils::Entry_#copy_file): open the source + file first to ensure it can be copied. [ruby-core:25498] + Wed Sep 9 21:20:49 2009 Nobuyoshi Nakada <nobu@r...> * ext/bigdecimal/bigdecimal.c (BigDecimal_data_type): typed. Index: lib/fileutils.rb =================================================================== --- lib/fileutils.rb (revision 24822) +++ lib/fileutils.rb (revision 24823) @@ -1261,8 +1261,10 @@ end def copy_file(dest) - File.open(dest, 'wb') do |f| - IO.copy_stream(path(), f) + File.open(path()) do |s| + File.open(dest, 'wb') do |f| + IO.copy_stream(s, f) + end end end Index: test/fileutils/test_fileutils.rb =================================================================== --- test/fileutils/test_fileutils.rb (revision 24822) +++ test/fileutils/test_fileutils.rb (revision 24823) @@ -223,6 +223,11 @@ assert_same_entry srcpath, destpath end + assert_raise(Errno::ENOENT) { + cp 'tmp/cptmp', 'tmp/cptmp_new' + } + assert_file_not_exist('tmp/cptmp_new') + # src==dest (1) same path touch 'tmp/cptmp' assert_raise(ArgumentError) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/