Class: Rant::Archive::Rubyzip::ZipStreamableStream
- Defined in:
- lib/rant/archive/rubyzip.rb
Overview
nodoc:all
Constant Summary
Constants inherited from ZipEntry
Rant::Archive::Rubyzip::ZipEntry::CDIR_ENTRY_STATIC_HEADER_LENGTH, Rant::Archive::Rubyzip::ZipEntry::CENTRAL_DIRECTORY_ENTRY_SIGNATURE, Rant::Archive::Rubyzip::ZipEntry::DEFLATED, Rant::Archive::Rubyzip::ZipEntry::LOCAL_ENTRY_SIGNATURE, Rant::Archive::Rubyzip::ZipEntry::LOCAL_ENTRY_STATIC_HEADER_LENGTH, Rant::Archive::Rubyzip::ZipEntry::STORED
Instance Attribute Summary
Attributes inherited from ZipEntry
#comment, #compressed_size, #compression_method, #crc, #externalFileAttributes, #extra, #fstype, #localHeaderOffset, #name, #size, #zipfile
Instance Method Summary collapse
- #get_input_stream ⇒ Object
- #get_output_stream ⇒ Object
-
#initialize(entry) ⇒ ZipStreamableStream
constructor
A new instance of ZipStreamableStream.
- #write_to_zip_output_stream(aZipOutputStream) ⇒ Object
Methods inherited from ZipEntry
#<=>, #==, #cdir_header_size, #directory?, #file?, #get_raw_input_stream, #local_entry_offset, #local_header_size, #next_header_offset, #parent_as_string, read_c_dir_entry, #read_c_dir_entry, read_local_entry, #read_local_entry, #time, #time=, #to_s, #write_c_dir_entry, #write_local_entry
Constructor Details
#initialize(entry) ⇒ ZipStreamableStream
Returns a new instance of ZipStreamableStream.
1316 1317 1318 1319 1320 |
# File 'lib/rant/archive/rubyzip.rb', line 1316 def initialize(entry) super(entry) @tempFile = Rant::Tempfile.new(File.basename(name), File.dirname(zipfile)) @tempFile.binmode end |
Instance Method Details
#get_input_stream ⇒ Object
1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 |
# File 'lib/rant/archive/rubyzip.rb', line 1334 def get_input_stream if ! @tempFile.closed? raise StandardError, "cannot open entry for reading while its open for writing - #{name}" end @tempFile.open # reopens tempfile from top if block_given? begin yield(@tempFile) ensure @tempFile.close end else @tempFile end end |
#get_output_stream ⇒ Object
1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 |
# File 'lib/rant/archive/rubyzip.rb', line 1322 def get_output_stream if block_given? begin yield(@tempFile) ensure @tempFile.close end else @tempFile end end |
#write_to_zip_output_stream(aZipOutputStream) ⇒ Object
1350 1351 1352 1353 |
# File 'lib/rant/archive/rubyzip.rb', line 1350 def write_to_zip_output_stream(aZipOutputStream) aZipOutputStream.put_next_entry(self) aZipOutputStream << get_input_stream { |is| is.read } end |