module Ronin::Support::Archive::Mixin

Provides helper methods for reading/writing archives.

@api public

@since 1.0.0

Public Instance Methods

tar(path,&block) click to toggle source

Opens the tar file for writing.

@param [String] path

The path to the file to write to.

@yield [tar]

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

@yieldparam [Tar::Writer] tar

The tar writer object.

@return [Tar::Writer]

The tar writer object.

@see tar_open

@api public

# File lib/ronin/support/archive/mixin.rb, line 132
def tar(path,&block)
  Archive.tar(path,&block)
end
tar_open(path, mode: 'r', &block) click to toggle source

Opens a tar file for reading or writing.

@param [String] path

The path to the tar file.

@param [String] mode

The mode to open the file as.

@yield [tar]

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

@yieldparam [Tar::Writer] tar

The tar writer object.

@return [Tar::Writer]

The tar writer object.

@raise [ArgumentError]

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

@see Tar.open

@api public

# File lib/ronin/support/archive/mixin.rb, line 86
def tar_open(path, mode: 'r', &block)
  Archive.tar_open(path, mode: mode, &block)
end
tar_stream(io, mode: 'r', &block) click to toggle source

Creates a tar stream around the IO object.

@param [IO, StringIO] io

The IO object to read or write data to.

@param [String] mode

The mode to open the tar stream with.

@yield [tar]

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

@yieldparam [Tar::Reader, Tar::Writer] tar

The tar reader or writer object.

@return [Tar::Reader, Tar::Writer]

The tar reader or writer object.

@raise [ArgumentError]

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

@see Tar.new

@api public

# File lib/ronin/support/archive/mixin.rb, line 57
def tar_stream(io, mode: 'r', &block)
  Archive.tar_stream(io, mode: mode, &block)
end
untar(path,&block) click to toggle source

Opens the tarped file for reading.

@param [String] path

The path to the file to read.

@yield [tar]

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

@yieldparam [Tar::Reader] tar

The tar reader object.

@return [Tar::Reader]

The tar reader object.

@see tar_open

@api public

# File lib/ronin/support/archive/mixin.rb, line 109
def untar(path,&block)
  Archive.untar(path,&block)
end
unzip(path,&block) click to toggle source

Opens the zipped file for reading.

@param [String] path

The path to the file to read.

@yield [zip]

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

@yieldparam [Zip::Reader] zip

The zip reader object.

@return [Zip::Reader]

The zip reader object.

@see zip_open

@api public

# File lib/ronin/support/archive/mixin.rb, line 184
def unzip(path,&block)
  Archive.unzip(path,&block)
end
zip(path,&block) click to toggle source

Opens the zip file for writing.

@param [String] path

The path to the file to write to.

@yield [zip]

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

@yieldparam [Zip::Writer] zip

The zip writer object.

@return [Zip::Writer]

The zip writer object.

@see zip_open

@api public

# File lib/ronin/support/archive/mixin.rb, line 207
def zip(path,&block)
  Archive.zip(path,&block)
end
zip_open(path, mode: 'r', &block) click to toggle source

Opens a zip file for reading or writing.

@param [String] path

The path to the zip file.

@param [String] mode

The mode to open the file as.

@yield [zip]

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

@yieldparam [Zip::Writer] zip

The zip writer object.

@return [Zip::Writer]

The zip writer object.

@raise [ArgumentError]

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

@see Zip.open

@api public

# File lib/ronin/support/archive/mixin.rb, line 161
def zip_open(path, mode: 'r', &block)
  Archive.zip_open(path, mode: mode, &block)
end