Class: Omnizip::Formats::Rar5::Reader
- Inherits:
-
Omnizip::Formats::Rar::RarFormatBase
- Object
- Omnizip::Formats::Rar::RarFormatBase
- Omnizip::Formats::Rar5::Reader
- Defined in:
- lib/omnizip/formats/rar5/reader.rb
Overview
RAR v5 archive reader
Adapter over the primary Formats::Rar::Reader — the one RAR5
parser verified against real archives and unrar — exposing the
legacy entry shape (uncompressed_size, modified_time, ...).
RAR 5 uses variable-length integers (vint) and improved header structure.
Defined Under Namespace
Classes: Entry, HeaderBlock
Constant Summary collapse
- METHOD_SYMBOLS =
RAR5 compression-method byte (cinfo bits 8-10) to the legacy symbol vocabulary
{ 0x30 => :store, 0x31 => :fastest, 0x32 => :fast, 0x33 => :normal, 0x34 => :good, 0x35 => :best, }.freeze
Instance Attribute Summary
Attributes inherited from Omnizip::Formats::Rar::RarFormatBase
Instance Method Summary collapse
-
#initialize ⇒ Reader
constructor
Initialize a RAR v5 reader.
-
#read_archive(io) ⇒ Array<Entry>
Read a RAR v5 archive.
Methods inherited from Omnizip::Formats::Rar::RarFormatBase
#block_type_code, #block_type_name, #compress, #compression_method_code, #compression_method_name, #decompress, #dictionary_size_code, #encryption_algorithm, #supports_feature?, #verify_magic_bytes, #write_archive
Constructor Details
#initialize ⇒ Reader
Initialize a RAR v5 reader
36 37 38 |
# File 'lib/omnizip/formats/rar5/reader.rb', line 36 def initialize super("rar5") end |
Instance Method Details
#read_archive(io) ⇒ Array<Entry>
Read a RAR v5 archive
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/omnizip/formats/rar5/reader.rb', line 45 def read_archive(io) data = io.read unless verify_magic_bytes(StringIO.new(data)) raise FormatError, "Invalid RAR v5 signature" end Dir.mktmpdir("omnizip_rar5_read") do |tmp| archive_path = File.join(tmp, "archive.rar") File.binwrite(archive_path, data) primary = Rar::Reader.new(archive_path) primary.open primary.list_files.map { |entry| adapt_entry(entry) } end end |