module Zip::IOExtras

def copy_stream(ostream, istream)

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

def copy_stream_n(ostream, istream, nbytes)

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