Skip to content

Writer

Sequential writer for a new TAR archive.

Fields

compression @ (:NONE: | :GZIP: | :ZSTD:) [get]

Selected compression as :NONE:, :GZIP:, or :ZSTD:.

Methods

create_dir path …

Creates a directory entry.

Parameters

NameTypeDescription
path (Str | fs.Path) Entry path.
:mode? Int Permission bits. Defaults to 0o755.
:uid? Int Owner ID. Defaults to 0.
:gid? Int Group ID. Defaults to 0.
:mtime? time.DateTime Modification time. Defaults to the Unix epoch.
:owner_name? Str Owner name.
:group_name? Str Group name.

Errors

Exception Condition
ValueError owner_name or group_name exceeds 32 bytes or contains a NUL

Example

archive.create_dir "subdir" mode: 0o755

entry[R] path :size func … -> R

Adds one regular-file entry and calls func with a scoped EntryWriter.

For directory, symlink, or hard-link entries, use create_dir, symlink, or hard_link instead -- none of them carry content, so none of them have any use for a write handle.

Parameters

NameTypeDescription
path (Str | fs.Path) Entry path.
:size Int Exact content size.
:mode? Int Permission bits. Defaults to 0o644.
:uid? Int Owner ID. Defaults to 0.
:gid? Int Group ID. Defaults to 0.
:mtime? time.DateTime Modification time. Defaults to the Unix epoch.
:owner_name? Str Owner name.
:group_name? Str Group name.
func ((EntryWriter) -> R) Entry writer scope, called with an EntryWriter.

Errors

Exception Condition
ConcurrencyError Another entry is created while an entry scope is active
ValueError The number of bytes written differs from the declared size
ValueError owner_name or group_name exceeds 32 bytes or contains a NUL

Example

archive.entry data.bin size: 4 mode: 0o600 do |entry|
  entry.write b"\x00\x01\x02\x03"

Creates a hard-link entry pointing to target.

Argument order matches fs.hard_link.

NameTypeDescription
target (Str | fs.Path) Path the hard link points to.
path (Str | fs.Path) Entry path.
:mode? Int Permission bits. Defaults to 0o644.
:uid? Int Owner ID. Defaults to 0.
:gid? Int Group ID. Defaults to 0.
:mtime? time.DateTime Modification time. Defaults to the Unix epoch.
:owner_name? Str Owner name.
:group_name? Str Group name.
Exception Condition
ValueError target is empty, exceeds 100 bytes, or contains a NUL
ValueError owner_name or group_name exceeds 32 bytes or contains a NUL
archive.hard_link "file.txt" "link.txt"

Creates a symbolic link entry pointing to target.

Argument order matches fs.symlink_file.

NameTypeDescription
target (Str | fs.Path) Path the symlink points to.
path (Str | fs.Path) Entry path.
:mode? Int Permission bits. Defaults to 0o777.
:uid? Int Owner ID. Defaults to 0.
:gid? Int Group ID. Defaults to 0.
:mtime? time.DateTime Modification time. Defaults to the Unix epoch.
:owner_name? Str Owner name.
:group_name? Str Group name.
Exception Condition
ValueError target is empty, exceeds 100 bytes, or contains a NUL
ValueError owner_name or group_name exceeds 32 bytes or contains a NUL
archive.symlink "target.txt" "link.txt"