Sha256: 6fa32b81f93a8af9f5239ee5ca3ea1b31279c8fb61c2164a615287fe53bc8c74

Contents?: true

Size: 727 Bytes

Versions: 45

Compression:

Stored size: 727 Bytes

Contents

module Zip
  class DecryptedIo #:nodoc:all
    CHUNK_SIZE = 32_768

    def initialize(io, decrypter)
      @io = io
      @decrypter = decrypter
    end

    def read(length = nil, outbuf = +'')
      return (length.nil? || length.zero? ? '' : nil) if eof

      while length.nil? || (buffer.bytesize < length)
        break if input_finished?

        buffer << produce_input
      end

      outbuf.replace(buffer.slice!(0...(length || output_buffer.bytesize)))
    end

    private

    def eof
      buffer.empty? && input_finished?
    end

    def buffer
      @buffer ||= +''
    end

    def input_finished?
      @io.eof
    end

    def produce_input
      @decrypter.decrypt(@io.read(CHUNK_SIZE))
    end
  end
end

Version data entries

45 entries across 35 versions & 8 rubygems

Version Path
rubyzip-2.4.1 lib/zip/crypto/decrypted_io.rb
rubyzip-2.4 lib/zip/crypto/decrypted_io.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/rubyzip-2.3.2/lib/zip/crypto/decrypted_io.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/rubyzip-2.3.2/lib/zip/crypto/decrypted_io.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/rubyzip-2.3.2/lib/zip/crypto/decrypted_io.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/rubyzip-2.3.2/lib/zip/crypto/decrypted_io.rb
rubyzip-2.4.rc1 lib/zip/crypto/decrypted_io.rb
tdiary-5.2.4 vendor/bundle/ruby/3.1.0/gems/rubyzip-2.3.2/lib/zip/crypto/decrypted_io.rb
lg_pod_plugin-1.0.8 lib/zip/crypto/decrypted_io.rb
lg_pod_plugin-1.0.7 lib/zip/crypto/decrypted_io.rb
lg_pod_plugin-1.0.6 lib/zip/crypto/decrypted_io.rb
tdiary-5.2.3 vendor/bundle/ruby/3.1.0/gems/rubyzip-2.3.2/lib/zip/crypto/decrypted_io.rb
tdiary-5.2.2 vendor/bundle/ruby/3.1.0/gems/rubyzip-2.3.2/lib/zip/crypto/decrypted_io.rb
tdiary-5.2.1 vendor/bundle/ruby/3.1.0/gems/rubyzip-2.3.2/lib/zip/crypto/decrypted_io.rb
vagrant-unbundled-2.2.19.0 vendor/bundle/ruby/3.0.0/gems/rubyzip-2.3.2/lib/zip/crypto/decrypted_io.rb
tdiary-5.2.0 vendor/bundle/ruby/3.0.0/gems/rubyzip-2.3.2/lib/zip/crypto/decrypted_io.rb
tdiary-5.2.0 vendor/bundle/ruby/2.7.0/gems/rubyzip-2.3.0/lib/zip/crypto/decrypted_io.rb
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/crypto/decrypted_io.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/crypto/decrypted_io.rb
vagrant-unbundled-2.2.18.0 vendor/bundle/ruby/3.0.0/gems/rubyzip-2.3.2/lib/zip/crypto/decrypted_io.rb