Class: Omnizip::Formats::Rar3::Reader
- Inherits:
-
Omnizip::Formats::Rar::RarFormatBase
- Object
- Omnizip::Formats::Rar::RarFormatBase
- Omnizip::Formats::Rar3::Reader
- Defined in:
- lib/omnizip/formats/rar3/reader.rb
Overview
RAR v3 (RAR4-family) archive reader
Adapter over the primary Formats::Rar::Reader — the one
parser verified against real WinRAR archives — exposing the
legacy entry shape (uncompressed_size, modified_time, ...).
Defined Under Namespace
Classes: Entry
Constant Summary collapse
- METHOD_SYMBOLS =
RAR4 method byte 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 v3 reader.
-
#read_archive(io) ⇒ Array<Entry>
Read a RAR v3 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 v3 reader
32 33 34 |
# File 'lib/omnizip/formats/rar3/reader.rb', line 32 def initialize super("rar3") end |
Instance Method Details
#read_archive(io) ⇒ Array<Entry>
Read a RAR v3 archive
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/omnizip/formats/rar3/reader.rb', line 41 def read_archive(io) data = io.read unless verify_magic_bytes(StringIO.new(data)) raise FormatError, "Invalid RAR v3 signature" end Dir.mktmpdir("omnizip_rar3_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 |