Class | Archive::Tar::Minitar::Writer
In: | lib/facets/more/minitar.rb
Parent: | Object

The class that writes a tar format archive to a data stream.

### Methods

add_file add_file_simple close flush mkdir new open

### Classes and Modules

Class Archive::Tar::Minitar::Writer::BoundedStream
Class Archive::Tar::Minitar::Writer::RestrictedStream

### Public Class methods

new(anIO)

Creates and returns a new Writer object.

open(anIO) {|writer| ...}

With no associated block, +Writer::open+ is a synonym for +Writer::new+. If the optional code block is given, it will be passed the new writer as an argument and the Writer object will automatically be closed when the block terminates. In this instance, +Writer::open+ returns the value of the block.

### Public Instance methods

add_file(name, opts = {}) {|RestrictedStream.new(@io), opts| ...}

Adds a file to the archive as `name`. `opts` must contain the following value:

`:mode`: | The Unix file permissions mode value.

`opts` may contain the following values:

`:uid`: The Unix file owner user ID number. `:gid`: The Unix file owner group ID number.

`:mtime`: | The integer modification time value.

The file‘s size will be determined from the amount of data written to the stream.

For add_file to be used, the Archive::Tar::Minitar::Writer must be wrapping a stream object that is seekable (e.g., it responds to pos=). Otherwise, add_file_simple must be used.

`opts` may be modified during the writing to the stream.

add_file_simple(name, opts = {}) {|os| ...}

Adds a file to the archive as `name`. `opts` must contain the following values:

`:mode`: | The Unix file permissions mode value.
`:size`: | The size, in bytes.

`opts` may contain the following values:

`:uid`: The Unix file owner user ID number. `:gid`: The Unix file owner group ID number.

`:mtime`: | The integer modification time value.

It will not be possible to add more than `opts[:size]` bytes to the file.

close()

Closes the Writer.

flush()

Passes the flush method to the wrapped stream, used for buffered streams.

mkdir(name, opts = {})

Creates a directory in the tar.

[Validate]