Class: Omnizip::Formats::Rar::Rar5::FileHeader

Inherits:
Header
  • Object
show all
Defined in:
lib/omnizip/formats/rar/rar5/header.rb

Overview

File header

Constant Summary collapse

FILE_IS_DIRECTORY =

File header flags. Per the RAR 5.0 spec, 0x0001 marks a directory entry (what this codebase once mislabeled as "has attributes" — attributes are an always-present field)

0x0001
FILE_HAS_MTIME =
0x0002
FILE_HAS_CRC32 =
0x0004
DICT_BASE =

Compression information field layout (RAR 5.0 spec): bits 0-5 algorithm version (0), bit 7 solid, bits 8-10 method (0=store, 1-5=LZMA), bits 11-15 dictionary size (128 KB * 2^N).

128 * 1024

Instance Attribute Summary

Attributes inherited from Header

#data_area_size, #extra_area, #flags, #header_data, #type

Instance Method Summary collapse

Methods inherited from Header

#encode

Constructor Details

#initialize(filename:, file_size:, compressed_size:, compression_method: 0, dict_size: 0, flags: 0, mtime: nil, crc32: nil, directory: false, extra_area: nil) ⇒ FileHeader

Returns a new instance of FileHeader.



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/omnizip/formats/rar/rar5/header.rb', line 122

def initialize(filename:, file_size:, compressed_size:,
               compression_method: 0, dict_size: 0,
               flags: 0, mtime: nil, crc32: nil,
               directory: false, extra_area: nil)
  # Build file flags based on what's provided
  file_flags = 0
  file_flags |= FILE_IS_DIRECTORY if directory
  file_flags |= FILE_HAS_MTIME if mtime
  file_flags |= FILE_HAS_CRC32 if crc32

  # Build header data with file information
  data = build_file_data(filename, file_size,
                         compression_method, dict_size,
                         file_flags, mtime, crc32,
                         directory: directory)
  super(HEADER_TYPE_FILE, flags: flags, data_area_size: compressed_size, header_data: data, extra_area: extra_area)
end