Class: ZipTricks::Streamer::Entry
- Inherits:
-
Struct
- Object
- Struct
- ZipTricks::Streamer::Entry
- Defined in:
- lib/zip_tricks/streamer/entry.rb
Overview
Is used internally by Streamer to keep track of entries in the archive during writing. Normally you will not have to use this class directly
Instance Attribute Summary collapse
-
#bytes_used_for_data_descriptor ⇒ Object
Returns the value of attribute bytes_used_for_data_descriptor.
-
#bytes_used_for_local_header ⇒ Object
Returns the value of attribute bytes_used_for_local_header.
-
#compressed_size ⇒ Object
Returns the value of attribute compressed_size.
-
#crc32 ⇒ Object
Returns the value of attribute crc32.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#local_header_offset ⇒ Object
Returns the value of attribute local_header_offset.
-
#mtime ⇒ Object
Returns the value of attribute mtime.
-
#storage_mode ⇒ Object
Returns the value of attribute storage_mode.
-
#uncompressed_size ⇒ Object
Returns the value of attribute uncompressed_size.
-
#unix_permissions ⇒ Object
Returns the value of attribute unix_permissions.
-
#use_data_descriptor ⇒ Object
Returns the value of attribute use_data_descriptor.
Instance Method Summary collapse
-
#gp_flags ⇒ Object
Set the general purpose flags for the entry.
-
#initialize ⇒ Entry
constructor
A new instance of Entry.
- #total_bytes_used ⇒ Object
Constructor Details
#initialize ⇒ Entry
Returns a new instance of Entry.
8 9 10 11 12 13 14 15 16 |
# File 'lib/zip_tricks/streamer/entry.rb', line 8 def initialize(*) super filename.force_encoding(Encoding::UTF_8) @requires_efs_flag = !(begin filename.encode(Encoding::ASCII) rescue false end) end |
Instance Attribute Details
#bytes_used_for_data_descriptor ⇒ Object
Returns the value of attribute bytes_used_for_data_descriptor
5 6 7 |
# File 'lib/zip_tricks/streamer/entry.rb', line 5 def bytes_used_for_data_descriptor @bytes_used_for_data_descriptor end |
#bytes_used_for_local_header ⇒ Object
Returns the value of attribute bytes_used_for_local_header
5 6 7 |
# File 'lib/zip_tricks/streamer/entry.rb', line 5 def bytes_used_for_local_header @bytes_used_for_local_header end |
#compressed_size ⇒ Object
Returns the value of attribute compressed_size
5 6 7 |
# File 'lib/zip_tricks/streamer/entry.rb', line 5 def compressed_size @compressed_size end |
#crc32 ⇒ Object
Returns the value of attribute crc32
5 6 7 |
# File 'lib/zip_tricks/streamer/entry.rb', line 5 def crc32 @crc32 end |
#filename ⇒ Object
Returns the value of attribute filename
5 6 7 |
# File 'lib/zip_tricks/streamer/entry.rb', line 5 def filename @filename end |
#local_header_offset ⇒ Object
Returns the value of attribute local_header_offset
5 6 7 |
# File 'lib/zip_tricks/streamer/entry.rb', line 5 def local_header_offset @local_header_offset end |
#mtime ⇒ Object
Returns the value of attribute mtime
5 6 7 |
# File 'lib/zip_tricks/streamer/entry.rb', line 5 def mtime @mtime end |
#storage_mode ⇒ Object
Returns the value of attribute storage_mode
5 6 7 |
# File 'lib/zip_tricks/streamer/entry.rb', line 5 def storage_mode @storage_mode end |
#uncompressed_size ⇒ Object
Returns the value of attribute uncompressed_size
5 6 7 |
# File 'lib/zip_tricks/streamer/entry.rb', line 5 def uncompressed_size @uncompressed_size end |
#unix_permissions ⇒ Object
Returns the value of attribute unix_permissions
5 6 7 |
# File 'lib/zip_tricks/streamer/entry.rb', line 5 def end |
#use_data_descriptor ⇒ Object
Returns the value of attribute use_data_descriptor
5 6 7 |
# File 'lib/zip_tricks/streamer/entry.rb', line 5 def use_data_descriptor @use_data_descriptor end |
Instance Method Details
#gp_flags ⇒ Object
Set the general purpose flags for the entry. We care about is the EFS bit (bit 11) which should be set if the filename is UTF8. If it is, we need to set the bit so that the unarchiving application knows that the filename in the archive is UTF-8 encoded, and not some DOS default. For ASCII entries it does not matter. Additionally, we care about bit 3 which toggles the use of the postfix data descriptor.
27 28 29 30 31 32 |
# File 'lib/zip_tricks/streamer/entry.rb', line 27 def gp_flags flag = 0b00000000000 flag |= 0b100000000000 if @requires_efs_flag # bit 11 flag |= 0x0008 if use_data_descriptor # bit 3 flag end |
#total_bytes_used ⇒ Object
18 19 20 |
# File 'lib/zip_tricks/streamer/entry.rb', line 18 def total_bytes_used bytes_used_for_local_header + compressed_size + bytes_used_for_data_descriptor end |