Module: Ronin::Support::Archive

Defined in:
lib/ronin/support/archive.rb,
lib/ronin/support/archive/tar.rb,
lib/ronin/support/archive/zip.rb,
lib/ronin/support/archive/mixin.rb,
lib/ronin/support/archive/tar/reader.rb,
lib/ronin/support/archive/tar/writer.rb,
lib/ronin/support/archive/zip/reader.rb,
lib/ronin/support/archive/zip/writer.rb,
lib/ronin/support/archive/zip/reader/entry.rb,
lib/ronin/support/archive/zip/reader/statistics.rb

Overview

Methods for reading or writing archive files.

Core-Ext Methods

Since:

  • 1.0.0

Defined Under Namespace

Modules: Mixin, Tar, Zip

Class Method Summary collapse

Class Method Details

.tar(path) {|tar| ... } ⇒ Tar::Writer

Opens the tar file for writing.

Parameters:

  • path (String)

    The path to the file to write to.

Yields:

  • (tar)

    If a block is given, it will be passed the tar writer object.

Yield Parameters:

Returns:

See Also:

Since:

  • 1.0.0



140
141
142
# File 'lib/ronin/support/archive.rb', line 140

def self.tar(path,&block)
  tar_open(path, mode: 'w', &block)
end

.tar_open(path, mode: 'r') {|tar| ... } ⇒ Tar::Writer

Opens a tar file for reading or writing.

Parameters:

  • path (String)

    The path to the tar file.

  • mode (String) (defaults to: 'r')

    The mode to open the file as.

Yields:

  • (tar)

    If a block is given, it will be passed the tar writer object.

Yield Parameters:

Returns:

Raises:

  • (ArgumentError)

    The mode must include either r, w, or a.

See Also:

Since:

  • 1.0.0



94
95
96
# File 'lib/ronin/support/archive.rb', line 94

def self.tar_open(path, mode: 'r', &block)
  Tar.open(path, mode: mode, &block)
end

.tar_stream(io, mode: 'r') {|tar| ... } ⇒ Tar::Reader, Tar::Writer

Creates a tar stream around the IO object.

Parameters:

  • io (IO, StringIO)

    The IO object to read or write data to.

  • mode (String) (defaults to: 'r')

    The mode to open the tar stream with.

Yields:

  • (tar)

    If a block is given, it will be passed the tar stream object.

Yield Parameters:

Returns:

Raises:

  • (ArgumentError)

    The mode must include either r, w, or a.

See Also:

Since:

  • 1.0.0



65
66
67
# File 'lib/ronin/support/archive.rb', line 65

def self.tar_stream(io, mode: 'r', &block)
  Tar.new(io, mode: mode, &block)
end

.untar(path) {|tar| ... } ⇒ Tar::Reader

Opens the tarped file for reading.

Parameters:

  • path (String)

    The path to the file to read.

Yields:

  • (tar)

    If a block is given, it will be passed the tar reader object.

Yield Parameters:

Returns:

See Also:

Since:

  • 1.0.0



117
118
119
# File 'lib/ronin/support/archive.rb', line 117

def self.untar(path,&block)
  tar_open(path,&block)
end

.unzip(path) {|zip| ... } ⇒ Zip::Reader

Opens the zipped file for reading.

Parameters:

  • path (String)

    The path to the file to read.

Yields:

  • (zip)

    If a block is given, it will be passed the zip reader object.

Yield Parameters:

Returns:

See Also:

Since:

  • 1.0.0



192
193
194
# File 'lib/ronin/support/archive.rb', line 192

def self.unzip(path,&block)
  zip_open(path,&block)
end

.zip(path) {|zip| ... } ⇒ Zip::Writer

Opens the zip file for writing.

Parameters:

  • path (String)

    The path to the file to write to.

Yields:

  • (zip)

    If a block is given, it will be passed the zip writer object.

Yield Parameters:

Returns:

See Also:

Since:

  • 1.0.0



215
216
217
# File 'lib/ronin/support/archive.rb', line 215

def self.zip(path,&block)
  zip_open(path, mode: 'w', &block)
end

.zip_open(path, mode: 'r') {|zip| ... } ⇒ Zip::Writer

Opens a zip file for reading or writing.

Parameters:

  • path (String)

    The path to the zip file.

  • mode (String) (defaults to: 'r')

    The mode to open the file as.

Yields:

  • (zip)

    If a block is given, it will be passed the zip writer object.

Yield Parameters:

Returns:

Raises:

  • (ArgumentError)

    The mode must include either r, w, or a.

See Also:

Since:

  • 1.0.0



169
170
171
# File 'lib/ronin/support/archive.rb', line 169

def self.zip_open(path, mode: 'r', &block)
  Zip.open(path, mode: mode, &block)
end