NAME
File::Raw::Archive::Writer - Archive entry emitter
SYNOPSIS
my $w = File::Raw::Archive->create("out.tar.gz",
compression => 'gzip', level => 9);
$w->add(name => 'README', content => $readme, mode => 0644);
$w->add(name => 'src/'); # directory
$w->add(name => 'src/main.c', content => $main_c);
$w->close;
DESCRIPTION
A File::Raw::Archive::Writer is returned by "create" in File::Raw::Archive. It appends entries to an open archive file one at a time.
METHODS
add(name => $name, %fields)-
Append one entry to the archive. Returns true. The entry type is inferred automatically from
nameandlink_targetwhentypeis not supplied: a trailing/innamegivesAE_DIR; alink_targetgivesAE_SYMLINK; everything else isAE_FILE.Recognised fields:
name-
Entry path as it should appear inside the archive. Required. A trailing
/marks a directory. content-
Byte string payload. May be omitted for directories and symlinks. When
sizeis not given it defaults tolength($content). type-
Integer entry type constant. Normally inferred; supply explicitly to emit hardlinks (
AE_HARDLINK) or device nodes (AE_FIFO,AE_CHAR,AE_BLOCK). mode-
POSIX permission bits. Defaults to
0755for directories,0777for symlinks, and0644for all other types. mtime-
Last-modification time as integer Unix seconds, or a floating-point value to encode sub-second precision (e.g.
1_700_000_000.5). mtime_ns-
Nanosecond component of the modification time. Ignored when
mtimeis already a floating-point value. uid/gid-
Numeric owner and group IDs. Default
0. link_target-
Symlink or hardlink destination path. Setting this field implies
type => AE_SYMLINKunlesstypeis given explicitly. xattrs-
Hashref of
name => bytespairs emitted as PAXSCHILY.xattr.*records. Binary values are base64-encoded automatically when the format requires it.
close-
Finalise the archive - for tar, writes the two mandatory trailing zero-filled 512-byte blocks - and release all resources. Idempotent; called automatically by
DESTROYif the caller forgets.
SEE ALSO
File::Raw::Archive, File::Raw::Archive::Entry.
AUTHOR
LNATION <email@lnation.org>
LICENSE AND COPYRIGHT
This software is Copyright (c) 2026 by LNATION <email@lnation.org>.
This is free software, licensed under the Artistic License 2.0 (GPL Compatible).