Sha256: 6a3cd95de0e37175818e5fee128f78df90b33f3df7dc0f6d5d38e94681f70e75

Contents?: true

Size: 1.26 KB

Versions: 14

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

# 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
class ZipTricks::Streamer::Entry < Struct.new(:filename, :crc32, :compressed_size,
                                              :uncompressed_size, :storage_mode, :mtime,
                                              :use_data_descriptor)
  def initialize(*)
    super
    filename.force_encoding(Encoding::UTF_8)
    @requires_efs_flag = !(begin
                             filename.encode(Encoding::ASCII)
                           rescue
                             false
                           end)
  end

  # 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.
  def gp_flags
    flag = 0b00000000000
    flag |= 0b100000000000 if @requires_efs_flag # bit 11
    flag |= 0x0008 if use_data_descriptor        # bit 3
    flag
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
zip_tricks-4.8.3 lib/zip_tricks/streamer/entry.rb
zip_tricks-4.8.2 lib/zip_tricks/streamer/entry.rb
zip_tricks-5.2.0 lib/zip_tricks/streamer/entry.rb
zip_tricks-4.8.1 lib/zip_tricks/streamer/entry.rb
zip_tricks-5.1.1 lib/zip_tricks/streamer/entry.rb
zip_tricks-5.1.0 lib/zip_tricks/streamer/entry.rb
zip_tricks-5.0.0 lib/zip_tricks/streamer/entry.rb
zip_tricks-4.8.0 lib/zip_tricks/streamer/entry.rb
zip_tricks-4.7.4 lib/zip_tricks/streamer/entry.rb
zip_tricks-4.7.3 lib/zip_tricks/streamer/entry.rb
zip_tricks-4.7.2 lib/zip_tricks/streamer/entry.rb
zip_tricks-4.7.1 lib/zip_tricks/streamer/entry.rb
zip_tricks-4.7.0 lib/zip_tricks/streamer/entry.rb
zip_tricks-4.6.0 lib/zip_tricks/streamer/entry.rb