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
-
#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.
-
#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.
-
#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.
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
#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 |
#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 |
#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.
23 24 25 26 27 28 |
# File 'lib/zip_tricks/streamer/entry.rb', line 23 def gp_flags flag = 0b00000000000 flag |= 0b100000000000 if @requires_efs_flag # bit 11 flag |= 0x0008 if use_data_descriptor # bit 3 flag end |