Class: Zip::DecryptedIo
- Inherits:
-
Object
- Object
- Zip::DecryptedIo
- Defined in:
- lib/zip/crypto/decrypted_io.rb
Overview
:nodoc:all
Constant Summary collapse
- CHUNK_SIZE =
32_768
Instance Method Summary collapse
-
#initialize(io, decrypter, compressed_size) ⇒ DecryptedIo
constructor
A new instance of DecryptedIo.
- #read(length = nil, outbuf = +'')) ⇒ Object
Constructor Details
#initialize(io, decrypter, compressed_size) ⇒ DecryptedIo
Returns a new instance of DecryptedIo.
7 8 9 10 11 12 |
# File 'lib/zip/crypto/decrypted_io.rb', line 7 def initialize(io, decrypter, compressed_size) @io = io @decrypter = decrypter @offset = io.tell @compressed_size = compressed_size end |
Instance Method Details
#read(length = nil, outbuf = +'')) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/zip/crypto/decrypted_io.rb', line 14 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 if @decrypter.kind_of?(::Zip::AESDecrypter) && input_finished? @decrypter.check_integrity(@io.read(::Zip::AESEncryption::AUTHENTICATION_CODE_LENGTH)) end outbuf.replace(buffer.slice!(0...(length || buffer.bytesize))) end |