Module: Ronin::Support::Archive::Mixin

Defined in:
lib/ronin/support/archive/mixin.rb

Overview

Provides helper methods for reading/writing archives.

Since:

  • 1.0.0

Instance Method Summary collapse

Instance 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



132
133
134
# File 'lib/ronin/support/archive/mixin.rb', line 132

def tar(path,&block)
  Archive.tar(path,&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



86
87
88
# 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') {|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



57
58
59
# 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) {|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



109
110
111
# File 'lib/ronin/support/archive/mixin.rb', line 109

def untar(path,&block)
  Archive.untar(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



184
185
186
# File 'lib/ronin/support/archive/mixin.rb', line 184

def unzip(path,&block)
  Archive.unzip(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



207
208
209
# File 'lib/ronin/support/archive/mixin.rb', line 207

def zip(path,&block)
  Archive.zip(path,&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



161
162
163
# File 'lib/ronin/support/archive/mixin.rb', line 161

def zip_open(path, mode: 'r', &block)
  Archive.zip_open(path, mode: mode, &block)
end