Class: ZipTricks::Streamer::Entry

Inherits:
Struct
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeEntry

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_sizeObject

Returns the value of attribute compressed_size

Returns:

  • (Object)

    the current value of compressed_size



5
6
7
# File 'lib/zip_tricks/streamer/entry.rb', line 5

def compressed_size
  @compressed_size
end

#crc32Object

Returns the value of attribute crc32

Returns:

  • (Object)

    the current value of crc32



5
6
7
# File 'lib/zip_tricks/streamer/entry.rb', line 5

def crc32
  @crc32
end

#filenameObject

Returns the value of attribute filename

Returns:

  • (Object)

    the current value of filename



5
6
7
# File 'lib/zip_tricks/streamer/entry.rb', line 5

def filename
  @filename
end

#mtimeObject

Returns the value of attribute mtime

Returns:

  • (Object)

    the current value of mtime



5
6
7
# File 'lib/zip_tricks/streamer/entry.rb', line 5

def mtime
  @mtime
end

#storage_modeObject

Returns the value of attribute storage_mode

Returns:

  • (Object)

    the current value of storage_mode



5
6
7
# File 'lib/zip_tricks/streamer/entry.rb', line 5

def storage_mode
  @storage_mode
end

#uncompressed_sizeObject

Returns the value of attribute uncompressed_size

Returns:

  • (Object)

    the current value of uncompressed_size



5
6
7
# File 'lib/zip_tricks/streamer/entry.rb', line 5

def uncompressed_size
  @uncompressed_size
end

#use_data_descriptorObject

Returns the value of attribute use_data_descriptor

Returns:

  • (Object)

    the current value of 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_flagsObject

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