Module: Zip::IOExtras

Defined in:
lib/zip/ioextras.rb,
lib/zip/ioextras/abstract_input_stream.rb,
lib/zip/ioextras/abstract_output_stream.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



9
10
11
# File 'lib/zip/ioextras.rb', line 9

def copy_stream(ostream, istream)
  ostream.write(istream.read(CHUNK_SIZE, '')) until istream.eof?
end

.copy_stream_n(ostream, istream, nbytes) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/zip/ioextras.rb', line 13

def copy_stream_n(ostream, istream, nbytes)
  toread = nbytes
  while toread > 0 && !istream.eof?
    tr = toread > CHUNK_SIZE ? CHUNK_SIZE : toread
    ostream.write(istream.read(tr, ''))
    toread -= tr
  end
end