Sha256: 5092b8ee9647a238b341c2d40c5fc5295c8fb6296ce0694fe2d4812326d82ba5

Contents?: true

Size: 918 Bytes

Versions: 3

Compression:

Stored size: 918 Bytes

Contents

module Zip
  module IOExtras #:nodoc:
    CHUNK_SIZE = 131_072

    RANGE_ALL = 0..-1

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

      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, ''.b))
          toread -= tr
        end
      end
    end

    # Implements kind_of? in order to pretend to be an IO object
    module FakeIO
      def kind_of?(object)
        object == IO || super
      end
    end
  end
end

require 'zip/ioextras/abstract_input_stream'
require 'zip/ioextras/abstract_output_stream'

# Copyright (C) 2002-2004 Thomas Sondergaard
# rubyzip is free software; you can redistribute it and/or
# modify it under the terms of the ruby license.

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubyzip-2.4.1 lib/zip/ioextras.rb
rubyzip-2.4 lib/zip/ioextras.rb
rubyzip-2.4.rc1 lib/zip/ioextras.rb