diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-01 02:31:56 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-01 02:31:56 +0000 |
commit | a107e1e998b36a956fd6c13a0a71bedfd52ac0bf (patch) | |
tree | ad8f70e611185f42ab6c10591367bcb057089dd2 /lib | |
parent | d4c52127946ebd2e6f9952d69d05cac5fe391740 (diff) | |
download | ruby-a107e1e998b36a956fd6c13a0a71bedfd52ac0bf.tar.gz |
* 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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/fileutils.rb | 16 |
1 files changed, 4 insertions, 12 deletions
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) |