Skip to content

Writer

Adds entries sequentially to a new TAR archive.

Fields

compression

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

Methods

entry path :size ... func

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:

Name Type Description
path Str|UnixPath Entry path
size Int Exact content size
mode Int? Permission bits; default 0o644
uid Int? Owner ID; default 0
gid Int? Group ID; default 0
mtime DateTime? Modification time; default Unix epoch
user_name Str? Owner name
group_name Str? Group name
func callable Entry writer scope

Returns: the result of func.

Errors:

  • Creating another entry while an entry scope is active raises a concurrency error.
  • Writing fewer or more bytes than size fails and prevents further entries.
archive.entry data.bin size: 4 mode: 0o600 do |entry|
  entry.write b"\x00\x01\x02\x03"

create_dir path :mode? :uid? :gid? :mtime? :user_name? :group_name?

Creates a directory entry.

Parameters:

Name Type Description
path Str|UnixPath Entry path
mode Int? Permission bits; default 0o755
uid Int? Owner ID; default 0
gid Int? Group ID; default 0
mtime DateTime? Modification time; default Unix epoch
user_name Str? Owner name
group_name Str? Group name
archive.create_dir "subdir" mode: 0o755

Creates a symbolic link entry pointing to target. Argument order matches fs.symlink_file.

Parameters:

Name Type Description
target Str|UnixPath Path the symlink points to
path Str|UnixPath Entry path
mode Int? Permission bits; default 0o777
uid Int? Owner ID; default 0
gid Int? Group ID; default 0
mtime DateTime? Modification time; default Unix epoch
user_name Str? Owner name
group_name Str? Group name
archive.symlink "target.txt" "link.txt"

Creates a hard-link entry pointing to target. Argument order matches fs.hard_link.

Parameters:

Name Type Description
target Str|UnixPath Path the hard link points to
path Str|UnixPath Entry path
mode Int? Permission bits; default 0o644
uid Int? Owner ID; default 0
gid Int? Group ID; default 0
mtime DateTime? Modification time; default Unix epoch
user_name Str? Owner name
group_name Str? Group name
archive.hard_link "file.txt" "link.txt"