Module: Zip::IOExtras
- Defined in:
- lib/zip/ioextras.rb
Overview
:nodoc:
Defined Under Namespace
Modules: AbstractInputStream, AbstractOutputStream, FakeIO
Constant Summary collapse
- CHUNK_SIZE =
131072
- RANGE_ALL =
0..-1
Class Method Summary collapse
Class Method Details
.copy_stream(ostream, istream) ⇒ Object
8 9 10 11 |
# File 'lib/zip/ioextras.rb', line 8 def self.copy_stream(ostream, istream) s = '' ostream.write(istream.read(CHUNK_SIZE, s)) until istream.eof? end |
.copy_stream_n(ostream, istream, nbytes) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/zip/ioextras.rb', line 13 def self.copy_stream_n(ostream, istream, nbytes) s = '' toread = nbytes while (toread > 0 && !istream.eof?) tr = toread > CHUNK_SIZE ? CHUNK_SIZE : toread ostream.write(istream.read(tr, s)) toread -= tr end end |