aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authoraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-01-01 07:22:04 +0000
committeraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-01-01 07:22:04 +0000
commit0a4a9dbaea37782ffe47210b26f2462f42ebff16 (patch)
treee8a708359dfa538585295c003d37eb0cc1beea52 /lib
parent41257b6d93728a6fa4ab5a4bf17e7ad20da1d880 (diff)
downloadruby-0a4a9dbaea37782ffe47210b26f2462f42ebff16.tar.gz
* lib/fileutils.rb (copy_stream): use read/write instead of sysread/syswrite, which allows duck typing. [ruby-dev:25369]
* lib/fileutils.rb (copy_stream): does NOT support nonblocking IO. [ruby-dev:25370] * test/fileutils/test_fileutils.rb: test copy_entry, copy_file, copy_stream. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7699 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/fileutils.rb20
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/fileutils.rb b/lib/fileutils.rb
index 38478cea71..18823e0cfe 100644
--- a/lib/fileutils.rb
+++ b/lib/fileutils.rb
@@ -47,12 +47,14 @@
#
# There are some `low level' methods, which does not accept any option:
#
-# uptodate?(file, cmp_list)
# copy_entry(src, dest, preserve = false, dereference = false)
# copy_file(src, dest, preserve = false, dereference = true)
# copy_stream(srcstream, deststream)
+# remove_file(path, force = false)
+# remove_dir(path, force = false)
# compare_file(path_a, path_b)
# compare_stream(stream_a, stream_b)
+# uptodate?(file, cmp_list)
#
# == module FileUtils::Verbose
#
@@ -434,18 +436,16 @@ module FileUtils
#
# Copies stream +src+ to +dest+.
- # Both of +src+ and +dest+ must be a IO.
+ # +src+ must be respond to #read(n) and
+ # +dest+ must be respond to #write(str).
#
def copy_stream(src, dest)
fu_copy_stream0 src, dest, fu_stream_blksize(src, dest)
end
def fu_copy_stream0(src, dest, blksize) #:nodoc:
- begin
- while true
- dest.syswrite src.sysread(blksize)
- end
- rescue EOFError
+ while s = src.read(blksize)
+ dest.write s
end
end
private :fu_copy_stream0
@@ -530,7 +530,11 @@ module FileUtils
end
def stat(path)
- @stat ||= ::File.stat(path)
+ if @dereference
+ @stat ||= ::File.stat(path)
+ else
+ @stat ||= ::File.lstat(path)
+ end
end
def chmod(mode, path)