From a107e1e998b36a956fd6c13a0a71bedfd52ac0bf Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 1 Sep 2008 02:31:56 +0000 Subject: * lib/fileutils.rb (copy_stream, fu_copy_stream0, copy_file): use IO.copy_stream to get rid of extraneous conversion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/fileutils.rb | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'lib/fileutils.rb') diff --git a/lib/fileutils.rb b/lib/fileutils.rb index 6152c3d306..83f1be82c5 100644 --- a/lib/fileutils.rb +++ b/lib/fileutils.rb @@ -470,7 +470,7 @@ module FileUtils # +dest+ must respond to #write(str). # def copy_stream(src, dest) - fu_copy_stream0 src, dest, fu_stream_blksize(src, dest) + IO.copy_stream(src, dest) end module_function :copy_stream @@ -1044,11 +1044,8 @@ module FileUtils /mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM end - def fu_copy_stream0(src, dest, blksize) #:nodoc: - # FIXME: readpartial? - while s = src.read(blksize) - dest.write s - end + def fu_copy_stream0(src, dest, blksize = nil) #:nodoc: + IO.copy_stream(src, dest) end def fu_stream_blksize(*streams) @@ -1254,12 +1251,7 @@ module FileUtils end def copy_file(dest) - st = stat() - File.open(path(), 'rb') {|r| - File.open(dest, 'wb', st.mode) {|w| - fu_copy_stream0 r, w, (fu_blksize(st) || fu_default_blksize()) - } - } + IO.copy_stream(path(), dest) end def copy_metadata(path) -- cgit v1.2.3