Class: Zip::ZipStreamableStream
Overview
nodoc:all
Constant Summary
Constants inherited from ZipEntry
Zip::ZipEntry::CDIR_ENTRY_STATIC_HEADER_LENGTH, Zip::ZipEntry::CENTRAL_DIRECTORY_ENTRY_SIGNATURE, Zip::ZipEntry::DEFLATED, Zip::ZipEntry::LOCAL_ENTRY_SIGNATURE, Zip::ZipEntry::LOCAL_ENTRY_STATIC_HEADER_LENGTH, Zip::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.
1310 1311 1312 1313 1314 |
# File 'lib/zip/zip.rb', line 1310 def initialize(entry) super(entry) @tempFile = Tempfile.new(File.basename(name), File.dirname(zipfile)) @tempFile.binmode end |
Instance Method Details
#get_input_stream ⇒ Object
1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 |
# File 'lib/zip/zip.rb', line 1328 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
1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 |
# File 'lib/zip/zip.rb', line 1316 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
1344 1345 1346 1347 |
# File 'lib/zip/zip.rb', line 1344 def write_to_zip_output_stream(aZipOutputStream) aZipOutputStream.put_next_entry(self) get_input_stream { |is| IOExtras.copy_stream(aZipOutputStream, is) } end |