Class: Zip::ZipStreamableStream
Overview
nodoc:all
Constant Summary
Constant Summary
Constants inherited from ZipEntry
Zip::ZipEntry::CDIR_ENTRY_STATIC_HEADER_LENGTH, Zip::ZipEntry::CENTRAL_DIRECTORY_ENTRY_SIGNATURE, Zip::ZipEntry::DEFLATED, Zip::ZipEntry::EFS, Zip::ZipEntry::FSTYPES, Zip::ZipEntry::FSTYPE_ACORN, Zip::ZipEntry::FSTYPE_AMIGA, Zip::ZipEntry::FSTYPE_ATARI, Zip::ZipEntry::FSTYPE_ATHEOS, Zip::ZipEntry::FSTYPE_BEOS, Zip::ZipEntry::FSTYPE_CPM, Zip::ZipEntry::FSTYPE_FAT, Zip::ZipEntry::FSTYPE_HPFS, Zip::ZipEntry::FSTYPE_MAC, Zip::ZipEntry::FSTYPE_MAC_OSX, Zip::ZipEntry::FSTYPE_MVS, Zip::ZipEntry::FSTYPE_NTFS, Zip::ZipEntry::FSTYPE_QDOS, Zip::ZipEntry::FSTYPE_TANDEM, Zip::ZipEntry::FSTYPE_THEOS, Zip::ZipEntry::FSTYPE_TOPS20, Zip::ZipEntry::FSTYPE_UNIX, Zip::ZipEntry::FSTYPE_VFAT, Zip::ZipEntry::FSTYPE_VMS, Zip::ZipEntry::FSTYPE_VM_CMS, Zip::ZipEntry::FSTYPE_Z_SYSTEM, Zip::ZipEntry::LOCAL_ENTRY_SIGNATURE, Zip::ZipEntry::LOCAL_ENTRY_STATIC_HEADER_LENGTH, Zip::ZipEntry::LOCAL_ENTRY_TRAILING_DESCRIPTOR_LENGTH, Zip::ZipEntry::STORED, Zip::ZipEntry::VERSION_NEEDED_TO_EXTRACT
Instance Attribute Summary
Attributes inherited from ZipEntry
#comment, #compressed_size, #compression_method, #crc, #externalFileAttributes, #extra, #filepath, #follow_symlinks, #fstype, #ftype, #gp_flags, #header_signature, #localHeaderOffset, #name, #restore_ownership, #restore_permissions, #restore_times, #size, #unix_gid, #unix_perms, #unix_uid, #zipfile
Instance Method Summary (collapse)
- - (Object) get_input_stream
- - (Object) get_output_stream
-
- (ZipStreamableStream) initialize(entry)
constructor
A new instance of ZipStreamableStream.
- - (Object) write_to_zip_output_stream(aZipOutputStream)
Methods inherited from ZipEntry
#<=>, #==, #calculate_local_header_size, #cdir_header_size, #comment_in, #directory?, #extract, #file?, #file_stat, #gather_fileinfo_from_srcpath, #get_extra_attributes_from_path, #get_raw_input_stream, #local_entry_offset, #name_encoding, #name_in, #name_is_directory?, #next_header_offset, #parent_as_string, #read_c_dir_entry, read_c_dir_entry, #read_local_entry, read_local_entry, #set_extra_attributes_on_path, set_unicode_names, #symlink?, #time, #time=, #to_s, unicode_names?, #write_c_dir_entry, #write_local_entry
Constructor Details
- (ZipStreamableStream) initialize(entry)
A new instance of ZipStreamableStream
3 4 5 6 7 |
# File 'lib/zip/zip_streamable_stream.rb', line 3 def initialize(entry) super(entry) @tempFile = Tempfile.new(File.basename(name), File.dirname(zipfile)) @tempFile.binmode end |
Instance Method Details
- (Object) get_input_stream
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/zip/zip_streamable_stream.rb', line 21 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 @tempFile.binmode if block_given? begin yield(@tempFile) ensure @tempFile.close end else @tempFile end end |
- (Object) get_output_stream
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/zip/zip_streamable_stream.rb', line 9 def get_output_stream if block_given? begin yield(@tempFile) ensure @tempFile.close end else @tempFile end end |
- (Object) write_to_zip_output_stream(aZipOutputStream)
38 39 40 41 |
# File 'lib/zip/zip_streamable_stream.rb', line 38 def write_to_zip_output_stream(aZipOutputStream) aZipOutputStream.put_next_entry(self) get_input_stream { |is| IOExtras.copy_stream(aZipOutputStream, is) } end |