* 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
This commit is contained in:
nobu 2008-09-01 02:31:56 +00:00
Родитель d4c5212794
Коммит a107e1e998
2 изменённых файлов: 9 добавлений и 12 удалений

Просмотреть файл

@ -1,3 +1,8 @@
Mon Sep 1 11:31:49 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/fileutils.rb (copy_stream, fu_copy_stream0, copy_file): use
IO.copy_stream to get rid of extraneous conversion.
Mon Sep 1 02:55:15 2008 NAKAMURA Usaku <usa@ruby-lang.org> Mon Sep 1 02:55:15 2008 NAKAMURA Usaku <usa@ruby-lang.org>
* strftime.c (rb_strftime): calc timezone offset by myself if system * strftime.c (rb_strftime): calc timezone offset by myself if system

Просмотреть файл

@ -470,7 +470,7 @@ module FileUtils
# +dest+ must respond to #write(str). # +dest+ must respond to #write(str).
# #
def copy_stream(src, dest) def copy_stream(src, dest)
fu_copy_stream0 src, dest, fu_stream_blksize(src, dest) IO.copy_stream(src, dest)
end end
module_function :copy_stream module_function :copy_stream
@ -1044,11 +1044,8 @@ module FileUtils
/mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM /mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM
end end
def fu_copy_stream0(src, dest, blksize) #:nodoc: def fu_copy_stream0(src, dest, blksize = nil) #:nodoc:
# FIXME: readpartial? IO.copy_stream(src, dest)
while s = src.read(blksize)
dest.write s
end
end end
def fu_stream_blksize(*streams) def fu_stream_blksize(*streams)
@ -1254,12 +1251,7 @@ module FileUtils
end end
def copy_file(dest) def copy_file(dest)
st = stat() IO.copy_stream(path(), dest)
File.open(path(), 'rb') {|r|
File.open(dest, 'wb', st.mode) {|w|
fu_copy_stream0 r, w, (fu_blksize(st) || fu_default_blksize())
}
}
end end
def copy_metadata(path) def copy_metadata(path)