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_HAS_ATTRIBUTES =

File header flags

0x0001
FILE_HAS_MTIME =
0x0002
FILE_HAS_CRC32 =
0x0004

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, flags: 0, mtime: nil, crc32: nil, extra_area: nil) ⇒ FileHeader

Returns a new instance of FileHeader.



105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/omnizip/formats/rar/rar5/header.rb', line 105

def initialize(filename:, file_size:, compressed_size:,
compression_method: 0, flags: 0, mtime: nil, crc32: nil, extra_area: nil)
  # Build file flags based on what's provided
  file_flags = 0
  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, compressed_size,
                         file_flags, compression_method, mtime, crc32)
  super(HEADER_TYPE_FILE, flags: flags, data_area_size: compressed_size, header_data: data, extra_area: extra_area)
end