Sha256: e4fdcc3cf8e8035f6dfb50a0be0a35fc3ae885aef9bae243e583a2c62112cb8f

Contents?: true

Size: 1.16 KB

Versions: 16

Compression:

Stored size: 1.16 KB

Contents

module Zip
  class PassThruDecompressor < Decompressor  #:nodoc:all
    def initialize(inputStream, charsToRead)
      super inputStream
      @charsToRead = charsToRead
      @readSoFar = 0
      @hasReturnedEmptyString = ! EMPTY_FILE_RETURNS_EMPTY_STRING_FIRST
    end

    # TODO: Specialize to handle different behaviour in ruby > 1.7.0 ?
    def sysread(numberOfBytes = nil, buf = nil)
      if input_finished?
        hasReturnedEmptyStringVal = @hasReturnedEmptyString
        @hasReturnedEmptyString = true
        return "" unless hasReturnedEmptyStringVal
        return
      end

      if (numberOfBytes == nil || @readSoFar + numberOfBytes > @charsToRead)
        numberOfBytes = @charsToRead - @readSoFar
      end
      @readSoFar += numberOfBytes
      @inputStream.read(numberOfBytes, buf)
    end

    def produce_input
      sysread(Decompressor::CHUNK_SIZE)
    end

    def input_finished?
      (@readSoFar >= @charsToRead)
    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

16 entries across 16 versions & 3 rubygems

Version Path
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/rubyzip-0.9.9/lib/zip/pass_thru_decompressor.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/rubyzip-0.9.8/lib/zip/pass_thru_decompressor.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/rubyzip-0.9.8/lib/zip/pass_thru_decompressor.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/rubyzip-0.9.8/lib/zip/pass_thru_decompressor.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/rubyzip-0.9.8/lib/zip/pass_thru_decompressor.rb
rubyzip-0.9.9 lib/zip/pass_thru_decompressor.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/rubyzip-0.9.8/lib/zip/pass_thru_decompressor.rb
rubyzip-0.9.8 lib/zip/pass_thru_decompressor.rb
rubyzip-0.9.7 lib/zip/pass_thru_decompressor.rb
frameworks-capybara-0.2.0.rc6 vendor/bundle/ruby/1.8/gems/rubyzip-0.9.6.1/lib/zip/pass_thru_decompressor.rb
frameworks-capybara-0.2.0.rc5 vendor/bundle/ruby/1.8/gems/rubyzip-0.9.6.1/lib/zip/pass_thru_decompressor.rb
frameworks-capybara-0.2.0.rc4 vendor/bundle/ruby/1.8/gems/rubyzip-0.9.6.1/lib/zip/pass_thru_decompressor.rb
frameworks-capybara-0.2.0.rc3 vendor/bundle/ruby/1.8/gems/rubyzip-0.9.6.1/lib/zip/pass_thru_decompressor.rb
frameworks-capybara-0.2.0.rc2 vendor/bundle/ruby/1.8/gems/rubyzip-0.9.6.1/lib/zip/pass_thru_decompressor.rb
rubyzip-0.9.6.1 lib/zip/pass_thru_decompressor.rb
rubyzip-0.9.5 lib/zip/pass_thru_decompressor.rb