Sha256: 0a7a84e0cece0670cee745226136d2136f85d5f31939224d64efeec6e8566e14

Contents?: true

Size: 1.1 KB

Versions: 29

Compression:

Stored size: 1.1 KB

Contents

module Zip
  class PassThruDecompressor < Decompressor #:nodoc:all
    def initialize(input_stream, chars_to_read)
      super(input_stream)
      @chars_to_read = chars_to_read
      @read_so_far = 0
      @has_returned_empty_string = false
    end

    def sysread(number_of_bytes = nil, buf = '')
      if input_finished?
        has_returned_empty_string_val = @has_returned_empty_string
        @has_returned_empty_string = true
        return '' unless has_returned_empty_string_val
        return
      end

      if number_of_bytes.nil? || @read_so_far + number_of_bytes > @chars_to_read
        number_of_bytes = @chars_to_read - @read_so_far
      end
      @read_so_far += number_of_bytes
      @input_stream.read(number_of_bytes, buf)
    end

    def produce_input
      sysread(::Zip::Decompressor::CHUNK_SIZE)
    end

    def input_finished?
      @read_so_far >= @chars_to_read
    end

    alias eof input_finished?
    alias eof? input_finished?
  end
end

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

Version data entries

29 entries across 24 versions & 4 rubygems

Version Path
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/pass_thru_decompressor.rb
tdiary-5.1.1 vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/pass_thru_decompressor.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.7.0/gems/rubyzip-1.3.0/lib/zip/pass_thru_decompressor.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.6.0/gems/rubyzip-1.2.3/lib/zip/pass_thru_decompressor.rb
rubyzip-2.1.0 lib/zip/pass_thru_decompressor.rb
tdiary-5.1.0 vendor/bundle/gems/rubyzip-2.0.0/lib/zip/pass_thru_decompressor.rb
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/rubyzip-1.2.4/lib/zip/pass_thru_decompressor.rb
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/pass_thru_decompressor.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/rubyzip-2.0.0/lib/zip/pass_thru_decompressor.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/rubyzip-2.0.0/lib/zip/pass_thru_decompressor.rb
vagrant-unbundled-2.2.6.1 vendor/bundle/ruby/2.6.0/gems/rubyzip-1.2.4/lib/zip/pass_thru_decompressor.rb
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/rubyzip-1.2.4/lib/zip/pass_thru_decompressor.rb
rubyzip-2.0.0 lib/zip/pass_thru_decompressor.rb
rubyzip-1.3.0 lib/zip/pass_thru_decompressor.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/rubyzip-1.2.2/lib/zip/pass_thru_decompressor.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/rubyzip-1.2.2/lib/zip/pass_thru_decompressor.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/rubyzip-1.2.4/lib/zip/pass_thru_decompressor.rb
rubyzip-1.2.4 lib/zip/pass_thru_decompressor.rb
rubyzip-1.2.3 lib/zip/pass_thru_decompressor.rb
tdiary-5.0.13 vendor/bundle/gems/rubyzip-1.2.2/lib/zip/pass_thru_decompressor.rb