Class: Ronin::Support::Archive::Tar::Writer
- Inherits:
-
Gem::Package::TarWriter
- Object
- Gem::Package::TarWriter
- Ronin::Support::Archive::Tar::Writer
- Defined in:
- lib/ronin/support/archive/tar/writer.rb
Overview
Handles writing tar encoded archive data.
Class Method Summary collapse
-
.new(io_or_buffer, mode: 'w') {|tar| ... } ⇒ Writer
Initializes the tar writer.
-
.open(path) {|tar| ... } ⇒ Writer
Opens the tar archive file for writing.
Instance Method Summary collapse
-
#add_file(name, contents = nil, mode: 0644) {|file| ... } ⇒ self
Adds a file to the tar archive.
-
#add_symlink(name, target, mode: 0777) ⇒ Object
Adds a symlink to the tar archive.
-
#allocate_file(name, size, mode: 0644) {|file| ... } ⇒ self
Adds a file, with the exact size, to the tar archive.
-
#mkdir(name, mode: 0755) ⇒ self
Adds a directory to the tar archive.
Class Method Details
.new(io_or_buffer, mode: 'w') {|tar| ... } ⇒ Writer
Initializes the tar writer.
69 70 71 72 73 74 75 76 |
# File 'lib/ronin/support/archive/tar/writer.rb', line 69 def self.new(io_or_buffer, mode: 'w', &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
#add_file(name, contents = nil, mode: 0644) {|file| ... } ⇒ self
Adds a file to the tar archive.
126 127 128 129 130 131 132 133 134 |
# File 'lib/ronin/support/archive/tar/writer.rb', line 126 def add_file(name,contents=nil, mode: 0644, &block) if contents super(name,mode) do |io| io.write(contents) end else super(name,mode,&block) end end |
#add_symlink(name, target, mode: 0777) ⇒ Object
Adds a symlink to the tar archive.
174 175 176 |
# File 'lib/ronin/support/archive/tar/writer.rb', line 174 def add_symlink(name,target, mode: 0777) super(name,target,mode) end |
#allocate_file(name, size, mode: 0644) {|file| ... } ⇒ self
Adds a file, with the exact size, to the tar archive.
158 159 160 |
# File 'lib/ronin/support/archive/tar/writer.rb', line 158 def allocate_file(name,size, mode: 0644, &block) add_file_simple(name,mode,size,&block) end |
#mkdir(name, mode: 0755) ⇒ self
Adds a directory to the tar archive.
189 190 191 |
# File 'lib/ronin/support/archive/tar/writer.rb', line 189 def mkdir(name, mode: 0755) super(name,mode) end |