Class: Ronin::Support::Archive::Tar::Reader
- Inherits:
-
Gem::Package::TarReader
- Object
- Gem::Package::TarReader
- Ronin::Support::Archive::Tar::Reader
- Defined in:
- lib/ronin/support/archive/tar/reader.rb
Overview
Handling reading tar encoded archive data.
Class Method Summary collapse
-
.new(io_or_buffer, mode: 'r') {|tar| ... } ⇒ Reader
Initializes the tar writer.
-
.open(path) {|tar| ... } ⇒ Reader
Opens the tar archive file for reading.
Instance Method Summary collapse
-
#[](name) ⇒ Entry?
Finds an entry in the tar archive with the matching name.
-
#read(name, length: nil) ⇒ String
Reads the contents of an entry from the tar archive.
Class Method Details
.new(io_or_buffer, mode: 'r') {|tar| ... } ⇒ Reader
Initializes the tar writer.
65 66 67 68 69 70 71 72 |
# File 'lib/ronin/support/archive/tar/reader.rb', line 65 def self.new(io_or_buffer, mode: 'r', &block) io = case io_or_buffer when String then StringIO.new(io_or_buffer,mode) else io_or_buffer end return super(io,&block) end |
Instance Method Details
#[](name) ⇒ Entry?
Finds an entry in the tar archive with the matching name.
109 110 111 |
# File 'lib/ronin/support/archive/tar/reader.rb', line 109 def [](name) find { |entry| entry.full_name == name } end |
#read(name, length: nil) ⇒ String
Reads the contents of an entry from the tar archive.
125 126 127 128 129 |
# File 'lib/ronin/support/archive/tar/reader.rb', line 125 def read(name, length: nil) if (entry = self[name]) entry.read(length) end end |