Package 'zuarchive'

Title: Read and Write ZIP and Tar Archives, and Read Compound Files
Description: Reads and writes ZIP and tar archives, and reads Compound File Binary files (Object Linking and Embedding, OLE2), member by member, from a path or from bytes held in memory. Every input is treated as hostile: entry counts, member sizes, total output and compression ratios are bounded by configurable limits, and member paths are sanitised so that extraction never writes outside its target directory. Writing is reproducible: the same inputs give the same bytes on every platform. A C interface lets other packages link the readers and writers directly.
Authors: Pedro Baltazar [aut, cre, cph], The Go Authors [cph] (ZIP and tar test files in tests/testthat/fixtures/go and tests/testthat/fixtures/go-tar)
Maintainer: Pedro Baltazar <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2026-12-05 08:10:57 UTC
Source: https://github.com/pedrobtz/zuarchive

Help Index


Extract an archive

Description

archive_extract() writes members of a ZIP or tar archive under a directory, and never anywhere else: every member's path is checked before anything is written, and a member whose path could land outside exdir refuses the whole extraction.

Usage

archive_extract(x, exdir, members = NULL, links = FALSE)

Arguments

x

A handle from archive_open(), or what it takes: a path to an archive or a raw vector holding one (opened with the default archive_limits()).

exdir

The directory to write into: a single path. It is created if it does not exist.

members

NULL to extract every member, or the names of the members to extract, as archive_list() shows them.

links

FALSE to refuse symbolic and hard link members, or TRUE to write those that stay inside exdir, as described above.

Details

Paths. A member name is split on /, and empty and . components are dropped (⁠a//./b⁠ is written as a/b). The extraction is refused, before anything is written, when a member to extract has a name with a .. component, a leading / (an absolute path), a backslash (a separator on Windows), a colon (a drive letter such as ⁠C:⁠, or a Windows stream), a NUL byte, or nothing left once cleaned; and on Windows, also a name that Windows would alias: a device name such as CON or aux.c, or a component ending in a dot or a space. So are two members that clean to the same path, and a member whose path another member needs as a directory.

Links. By default (links = FALSE) a symbolic link or hard link member refuses the extraction. With links = TRUE:

  • a symbolic link (tar, or ZIP, where the link's target is the member's bytes) is created when its target, read from the link's own directory, stays inside exdir: not absolute, .. only at its start and no more of them than the link has directories above it, and not exdir itself. The target is checked as written, never by following links on disk, and is written in its plain form (⁠./a//b⁠ as a/b). A member to be written through a link created earlier is refused, as any link in the way is.

  • a tar hard link is written as a copy of the member it names, which must be a file extracted earlier in the same call.

An absolute target, or one leading out of exdir, refuses the extraction whatever links says. On Windows, creating a symbolic link takes a privilege (or Developer Mode); without it, a symbolic link member raises an error naming the member and the privilege.

Nothing is overwritten. Each file and link is created anew: a file, directory or link already at a member's path refuses that member, and so does a symbolic link among the directories above it. On a file system that ignores case, two names differing only in case are caught this way, when the second is written. Directories that exist already are used.

Checked first. Before anything is written, every member to extract is checked as archive_read() checks it: limits, encryption, compression method. A member found corrupt while it is written (a CRC-32 mismatch, a broken DEFLATE stream) stops the extraction: its file is removed, and the members written before it stay, listed in the condition's written field. A tar archive is walked whole when it is opened, so a tar member cut short by the end of the archive refuses the extraction before anything is written.

Member times and permissions are not restored: each file is written as the process creates files.

Value

The paths written, invisibly: exdir joined with each extracted member's cleaned name, in the archive's order. Directory and link members are included. A member is written under the UTF-8 bytes of its name in every locale; off Windows, in a locale that is not UTF-8, a path whose name is not ASCII is returned as a native string holding those bytes, so that file.exists() and the other file functions of R find the file.

Conditions

Every refusal is an error of class zuarchive_error and a subclass. Those of archive_open() and archive_read(), and:

  • zuarchive_error_path: a member's name is not a safe relative path, two members would be written to one path, a member is a link and links is FALSE, a link's target leads outside exdir or a hard link names no file extracted before it, a symbolic link cannot be created for lack of privilege, something is already at a member's path; exdir is not a single path or names a file; members is not a character vector without NA or repeated names; links is not TRUE or FALSE.

  • zuarchive_error_not_found: a name in members is no member of the archive.

  • zuarchive_error_format: the archive is a Compound File, whose stream names may hold control characters that some file systems cannot store, so this version reads them with archive_read() only; or a tar member is a device, a FIFO or a sparse file.

A failure to create a directory or write a file raises zuarchive_error with no subclass. Each condition carries member, the member's name, where one member is at fault, and written, the paths written before the failure.

See Also

archive_write(), archive_read()

Examples

zip <- system.file("extdata", "hello.zip", package = "zuarchive")
out <- tempfile()
archive_extract(zip, out)
readLines(file.path(out, "hello.txt"), warn = FALSE)

Detect the format of an archive

Description

archive_format() names the container format the bytes start with, from the magic numbers the format specifications define. It reads at most the first 512 bytes of a file.

Usage

archive_format(x)

Arguments

x

A path to a file (a single string), a raw vector, or a handle from archive_open().

Details

The magic numbers are, at the offsets the specifications give:

  • ZIP (APPNOTE.TXT 4.3.7 and 4.3.16): a local file header, ⁠PK\3\4⁠, or, for an archive with no members, the end of central directory record, ⁠PK\5\6⁠, at offset 0.

  • tar (POSIX ustar): ⁠ustar\0⁠ at offset 257, or GNU tar's ⁠ustar \0⁠.

  • Compound File (MS-CFB, section 2.2): ⁠D0 CF 11 E0 A1 B1 1A E1⁠ at offset 0.

ZIP and Compound File are tried first, because a tar archive starts with a member name, which may be any bytes. A ZIP archive with data before its first member, such as a self-extracting one, and a tar archive older than POSIX ustar are not detected; archive_open() opens them when given format.

Bytes with none of those magic numbers that start with gzip's (⁠1F 8B⁠, RFC 1952), zstd's (⁠28 B5 2F FD⁠, RFC 8878) or an LZ4 frame's (⁠04 22 4D 18⁠) are decoded until they yield 512 bytes, and those are looked at for tar's magic number: a .tar.gz, .tar.zst or .tar.lz4 is "tar". Nothing else is read inside a compression, so a gzip of a ZIP archive is NA.

Value

"zip", "tar", "cfb", or NA when the bytes start with none of those magic numbers. For a handle, the format it reads the archive as.

Conditions

zuarchive_error_path when x is none of the three, is NA or empty, or names a directory; zuarchive_error_not_found when the path does not exist or cannot be read. A handle that is not open raises zuarchive_error; one whose file has changed format since it was opened raises zuarchive_error_format.

See Also

archive_open()

Examples

archive_format(as.raw(c(0x50, 0x4b, 0x03, 0x04)))   # ZIP local header
archive_format(as.raw(c(0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1)))
archive_format(charToRaw("plain text"))

Limits for reading hostile archives

Description

Every reader treats its input as hostile. archive_limits() collects the bounds it enforces, for archive_open() to attach to a handle; the readers (archive_list(), archive_read(), archive_stream() and archive_extract()) check every member against them before handing over its bytes.

Usage

archive_limits(
  max_entries = 1e+06,
  max_member = 2^30,
  max_total = 2^32,
  max_ratio = 1000,
  max_name = 4096
)

Arguments

max_entries

Most members an archive may hold. A whole number from 1 to .Machine$integer.max.

max_member

Most uncompressed bytes of any one member. A whole number from 1 to 2^53, the largest a double holds exactly.

max_total

Most uncompressed bytes of all members together. A whole number from 1 to 2^53. For a tar compressed with gzip, zstd or lz4 it also bounds every byte the stream decodes to, headers and padding included, counted as they are decoded.

max_ratio

Largest ratio of a member's uncompressed bytes to its compressed bytes. A number from 1 to .Machine$integer.max; it need not be whole. DEFLATE cannot exceed about 1032:1, so the default stops a member compressed near that bound. tar and Compound File members are not compressed, so it does not apply to them; for a tar compressed with gzip, zstd or lz4 it bounds the bytes the whole stream decodes to over the compressed file's, counted as they are decoded.

max_name

Most bytes in a member name. A whole number from 1 to .Machine$integer.max.

Value

A list of class zuarchive_limits holding the five limits as doubles, in the order of the arguments.

Conditions

A value that is missing (NA, NaN), not a single number, infinite, fractional where a whole number is required, or outside its range raises an error of class zuarchive_error_limit, which inherits from zuarchive_error.

See Also

archive_open()

Examples

archive_limits()
archive_limits(max_member = 64 * 1024^2, max_ratio = 100)

List the members of an archive

Description

archive_list() returns one row per member of the archive, in the order of the archive's central directory, duplicates included.

Usage

archive_list(z)

Arguments

z

A handle from archive_open().

Details

Before listing, the whole central directory is checked against the handle's archive_limits(): more members than max_entries, a name longer than max_name bytes, or declared sizes adding up to more than max_total refuse the archive, as do members that lie outside the bytes before the central directory or overlap one another. Nothing is inflated.

Names are returned in UTF-8. A name that is well-formed UTF-8 is read as UTF-8, whether or not the archive sets the UTF-8 flag; any other name is read as IBM code page 437, the encoding the ZIP specification gives names without the flag.

Times. A ZIP member's MS-DOS date and time carry no time zone. They are read as UTC, so mtime is the same in every session whatever its time zone, and shows the clock time the writer stored when printed in UTC. When the member carries one of the extra fields that record a time in UTC (extended timestamp 0x5455, NTFS 0x000a, or the Unix fields 0x000d and 0x5855), mtime comes from it instead: the last such field wins, as in Go's archive/zip.

Compound Files ("OLE2": legacy .doc, .xls, .ppt, encrypted Office files) have one row per storage and stream, the root entry excepted. Each is named by its path from the root entry, its own name included and components joined by /, such as "Root Entry/WordDocument". Storages come before what they hold, and each storage's children are in the order the format sorts them (by name length, then name). A storage is a "directory" of size 0; a stream is a "file", "stored", with compressed equal to size. mtime is NA where the entry records no time, and encrypted is always FALSE: an encrypted Office document is ordinary streams to the container. The same limits apply, but max_ratio; max_name counts the bytes of the whole UTF-8 path. Every sector chain the listing needs is checked first.

tar archives (ustar, pax, GNU and older formats, plain or compressed with gzip, zstd or lz4) have one row per member, in the order of the archive. Every header is read and checked first, as Go's archive/tar reads one, and every member's data must lie inside the input. A pax path record or a GNU long name gives the name; a name that is not well-formed UTF-8 is read as ISO 8859-1. mtime keeps the fraction of a second a pax record carries. Directories and links have size 0; a symbolic or hard link's target is not listed. A GNU sparse file is listed with its expanded size and method "sparse", and is not read. Devices, FIFOs and other special members are of type "other". Global pax headers are checked but are not members. The same limits apply, but max_ratio: max_total counts the members' sizes.

A tar compressed with gzip, zstd or lz4 (detected from its bytes: .tar.gz, .tgz, .tar.zst, .tar.lz4) lists exactly as the plain tar would, members "stored". The whole stream is decoded and checked first, so a stream that is corrupt, cut short or followed by other bytes is refused before anything is listed; gzip members and zstd or lz4 frames that follow one another are one stream. Here max_total also bounds every byte the stream decodes to (the tar's headers and padding included), and max_ratio those bytes over the compressed file's. bzip2, xz and compress are not read.

Value

A data frame with one row per member and the columns:

  • name: the member name, in UTF-8.

  • size: the uncompressed size in bytes, as the archive declares it.

  • compressed: the compressed size in bytes.

  • method: the compression method: "stored", "deflate", "zstd", or the name of one zuarchive cannot read ("deflate64", "bzip2", "lzma", "xz", "ppmd", "aes"), "sparse" for a GNU sparse tar member, or "method <n>" for any other.

  • mtime: the modification time, a POSIXct in UTC.

  • type: "file", "directory" or "symlink"; in a tar archive also "hardlink", and "other" for a device, a FIFO or another special member.

  • encrypted: TRUE for a member encrypted with ZipCrypto, strong encryption or WinZip AES.

Conditions

Every refusal is an error of class zuarchive_error and a subclass:

  • zuarchive_error_limit: a limit is exceeded; the condition's limit field names it.

  • zuarchive_error_malformed: the central directory is missing, truncated or inconsistent, or members overlap or point outside the archive. For a Compound File: a bad header, a sector chain that loops or leaves the file, a directory tree that reaches an entry twice, or a stream declared larger than the file. For tar: a header whose checksum or numbers are wrong, a pax record that lies about its length, a member cut short by the end of the input, an end marker followed by more headers, a pax or GNU long-name record with no member after it, or a gzip, zstd or lz4 stream that is corrupt, cut short or followed by other bytes.

  • zuarchive_error_crc: a compressed tar's stream does not match its own checksum (gzip's CRC-32, a zstd or lz4 content checksum).

  • zuarchive_error_encrypted: the central directory itself is encrypted.

  • zuarchive_error_format: a feature zuarchive does not read, such as a multi-disk archive, or a tar compressed with bzip2, xz or compress.

  • zuarchive_error_path: a member name contains a NUL byte (in a tar archive, a pax path or link target with one); in a Compound File, a name that is empty or contains /.

  • zuarchive_error_not_found: the handle's file has gone.

z that is not a handle, or a handle that is not open, raises zuarchive_error.

See Also

archive_read(), archive_stream(), archive_open()

Examples

z <- archive_open(system.file("extdata", "hello.zip", package = "zuarchive"))
archive_list(z)

Open an archive

Description

archive_open() returns a handle over a ZIP, tar or Compound File archive, held as a path or as a raw vector in memory. The format comes from the bytes, never from the file name.

Usage

archive_open(x, format = NULL, limits = archive_limits())

Arguments

x

A path to an archive (a single string), or a raw vector holding one.

format

NULL to detect the format from the bytes, or one of "zip", "tar" or "cfb" to read the archive as that format. A given format must not contradict the bytes; it is needed for input whose format has no magic number, such as a tar written before POSIX ustar.

limits

The limits the readers enforce, from archive_limits().

Details

A handle over a raw vector keeps that vector alive for as long as the handle exists, so the caller may drop its own reference. Changing the caller's copy afterwards does not change the bytes the handle reads.

A handle over a path holds no open file between calls: each use opens the path again, so the handle survives a change of working directory (the path is made absolute at open) and sees the file as it is when used. If the file has gone, using the handle raises zuarchive_error_not_found; if it now holds a different format, zuarchive_error_format.

A handle cannot be saved: one restored by readRDS() or unserialize() raises zuarchive_error when used. Open the archive again instead.

Value

An object of class zuarchive_handle.

Conditions

Each refusal is an error of class zuarchive_error and a subclass:

  • zuarchive_error_path: x is neither a single path nor a raw vector, is NA or empty, or names a directory.

  • zuarchive_error_not_found: the path does not exist or cannot be read.

  • zuarchive_error_format: the bytes are of no format zuarchive reads, format is not one of the three, or format contradicts the bytes.

  • zuarchive_error_limit: limits was not made by archive_limits().

See Also

archive_format(), archive_limits()

Examples

# An empty ZIP archive is its end-of-central-directory record alone.
empty_zip <- as.raw(c(0x50, 0x4b, 0x05, 0x06, rep(0, 18)))
z <- archive_open(empty_zip)
z
archive_format(z)

Read one member of an archive

Description

archive_read() returns the bytes of one member, inflated and checked against the member's CRC-32, as a raw vector or as a string.

Usage

archive_read(z, name, as = "raw")

Arguments

z

A handle from archive_open().

name

The member's name: a single string, compared with the members' names after conversion to UTF-8.

as

"raw" for a raw vector, or "text" for a single string marked as UTF-8. Text must be well-formed UTF-8 without NUL bytes; it is returned byte for byte, a byte order mark included.

Details

The member is found by its exact name, as archive_list() shows it. Before anything is inflated, the member is checked against the handle's archive_limits() (max_member, max_ratio, and the archive-wide limits archive_list() checks); while it is inflated, it may not grow past the size the archive declares. A member that fails any check returns nothing: the whole member is read and checked before a value is returned.

A name that more than one member carries is refused: ZIP readers disagree on which of them it means, so zuarchive reads none.

In a Compound File, name is a stream's path as archive_list() shows it, root entry first. A storage reads as raw(0). The format compares names without regard to case, so two paths that differ only in the case of ASCII letters are one name, and reading either is refused. The stream's sector chain is checked whole before its first byte is read.

In a tar archive, a directory or a link reads as raw(0); a sparse file or an "other" member raises zuarchive_error_format. A name that more than one member carries is refused, as for ZIP.

Value

A raw vector, or for as = "text" a character string of length one.

Conditions

Every refusal is an error of class zuarchive_error and a subclass. Those of archive_list(), and:

  • zuarchive_error_not_found: no member has that name.

  • zuarchive_error_crc: the member's bytes do not match its CRC-32.

  • zuarchive_error_malformed: the member's data is corrupt, ends early, does not decode to the declared size, or lies outside its bounds; or more than one member has that name. For a Compound File, the stream's sector chain is broken or shorter than its size.

  • zuarchive_error_encrypted: the member is encrypted.

  • zuarchive_error_format: the member is compressed with a method other than stored, DEFLATE or Zstandard (method 93), is a sparse or special tar member, or, for as = "text", is not UTF-8 text; or as is neither "raw" nor "text".

  • zuarchive_error_limit: max_member or max_ratio is exceeded.

  • zuarchive_error_path: name is not a single non-empty string.

The condition carries member, the name asked for.

See Also

archive_stream() to read a large member in pieces, archive_list()

Examples

z <- archive_open(system.file("extdata", "hello.zip", package = "zuarchive"))
archive_read(z, "hello.txt")
archive_read(z, "hello.txt", as = "text")

Read one member of an archive in chunks

Description

archive_stream() inflates one member and calls callback with each chunk of its bytes, in order, so a member larger than memory can be processed. The member is found and checked as archive_read() does.

Usage

archive_stream(z, name, callback, chunk_size = 65536)

Arguments

z

A handle from archive_open().

name

The member's name: a single string, compared with the members' names after conversion to UTF-8.

callback

A function called as callback(chunk) for each chunk, chunk being a raw vector. Its value is ignored.

chunk_size

The size of each chunk in bytes, the last excepted. A whole number from 1 to .Machine$integer.max.

Details

Chunks are handed over as they are inflated, so the CRC-32 can only be compared after the last one: when it does not match, callback has already seen every byte of the member, and the error's delivered field says how many. A member that is corrupt part-way stops at the first corrupt byte, and delivered counts the bytes handed over until then; it never exceeds the size the archive declares. Every chunk but the last of a complete member has exactly chunk_size bytes, so the bytes inflated after the last whole chunk and before the corrupt byte are not handed over.

A Compound File stream is stored, not compressed, and has no CRC-32. Its whole sector chain is checked before the first chunk, so a broken stream raises an error with delivered 0 and callback is never called. A tar member is stored too, and its data was found whole when the archive was opened; a file that shrinks while it is read stops at the last whole chunk. A compressed tar's whole stream is decoded and checked when the archive is opened, so a corrupt one raises an error with delivered 0 before callback is called.

An error raised by callback stops the stream and is passed on as it is; the archive is closed on the way out, so the handle can be read again at once.

Value

The number of bytes handed to callback, invisibly.

Conditions

Those of archive_read(), each with delivered, the number of bytes callback received before the failure, and:

  • zuarchive_error_limit: chunk_size is not a whole number from 1 to .Machine$integer.max.

  • zuarchive_error: callback is not a function.

See Also

archive_read()

Examples

z <- archive_open(system.file("extdata", "hello.zip", package = "zuarchive"))
archive_stream(z, "hello.txt", function(chunk) print(rawToChar(chunk)),
  chunk_size = 2)

Write an archive

Description

archive_write() writes files into a new ZIP or tar archive, one member per file, in the order given. The same files, names, times and compression give the same bytes on every platform: the archive holds nothing about the machine that wrote it.

Usage

archive_write(
  path,
  files,
  format = "zip",
  names = basename(files),
  mtime = "fixed",
  compression = NULL
)

Arguments

path

Where to write the archive: a single path. An existing file there is replaced.

files

The files to archive: a character vector of paths. Each must be a regular file (or a link to one); a directory, device, FIFO or socket is refused before any file is opened. May be empty, which writes an archive with no members.

format

"zip" or "tar".

names

The member names, one per file: a character vector as long as files. By default, the files' base names.

mtime

"fixed"; "file", each file's own modification time (file.mtime()); or the members' modification times: a POSIXct of length one (for every member) or as long as files. Either way each time must lie from 1980-01-01 00:00:00 to 2107-12-31 23:59:58 UTC for ZIP, or from 1970-01-01 00:00:00 to 2242-03-16 12:56:31 UTC for tar.

compression

NULL for the format's default, or how members are stored. ZIP takes "deflate" (the default) or "stored"; members of three bytes or fewer are always stored, as DEFLATE cannot shrink them. tar takes "stored" (the default, as tar does not compress members).

Details

Reproducible. Members are written in the order of files, with the names given and nothing about the host (no owner, permissions, host times or ZIP extra fields), compressed at a fixed DEFLATE level, and dated by mtime alone. With mtime = "fixed" (the default) every member is dated 1980-01-01 00:00:00 UTC, the first time a ZIP member can carry, in tar as in ZIP, so writing the same files twice, anywhere, gives identical archives.

tar. With format = "tar" each member is a POSIX ustar header (mode 0644, owner and group 0 with no names) and the file's bytes. A name longer than 100 bytes or not ASCII, and a file of 8 GiB or more, is written with a pax extended header before it, which every current tar reads; the ustar prefix field is never used. The archive ends with the two zero blocks tar requires and is not padded further. Times are whole seconds (a fraction is dropped) from 1970-01-01 00:00:00 to 2242-03-16 12:56:31 UTC, the range of the ustar time field. Members are not compressed: compress the whole archive with another tool if needed.

Times. A ZIP member's time is the MS-DOS date and time, which has no time zone and a resolution of two seconds. zuarchive stores the UTC date and time of mtime, rounded down to an even second, and reads it back as UTC, so archive_list() returns it unchanged in any time zone. To date members as the files are, pass mtime = "file".

ZIP64. The archive uses the ZIP64 records when it needs them, decided from the inputs before anything is written: when it has 65535 members or more, a member of 4 GiB (2^32 - 1 bytes) or more, or members that could add up to that much. Otherwise it is a plain ZIP that any reader opens.

Names must be relative paths that archive_extract() would accept, written in their plain form: no .. component, no leading /, no backslash, colon or NUL, no empty or . component, no trailing /. They are stored in UTF-8, with the archive's UTF-8 flag set. A name can be used once, and cannot also be the directory of another ("a" and "a/b").

The archive is written to a temporary file beside path and renamed into place when it is complete, so a failure leaves no partial archive and does not touch an existing file at path.

Value

path, invisibly.

Conditions

Each refusal is an error of class zuarchive_error and a subclass:

  • zuarchive_error_path: path is not a single path or names a directory; files is not a character vector without NA or empty strings, or names a directory, a device, a FIFO or a socket (anything but a regular file, or a link to one); names is not a character vector as long as files, or holds a name that is NA, empty, longer than 65535 bytes (in either format), not a safe relative path in its plain form, repeated, or the directory of another name ("a" with "a/b"), which archive_extract() would refuse.

  • zuarchive_error_not_found: a file in files does not exist or cannot be read, or the directory path would go in does not exist.

  • zuarchive_error_format: format, mtime or compression is not one of the values above (with mtime = "file", a file dated outside the format's range, named in the condition), or compression is one the format cannot use ("deflate" for tar); or a member cannot be represented in a ZIP archive as miniz writes one (a DEFLATE member of 4 GiB or more whose compressed bytes would start past the first 4 GiB of the archive, or incompressible data within a few hundred kilobytes under 4 GiB).

A failure to write the archive itself (a full disk) raises zuarchive_error with no subclass. Conditions about one member carry member, its name, and path, its file.

See Also

archive_extract(), archive_list()

Examples

src <- tempfile()
dir.create(src)
writeLines("Hello, archive.", file.path(src, "hello.txt"))
writeLines(c("x,y", "1,2"), file.path(src, "data.csv"))

out <- tempfile(fileext = ".zip")
archive_write(out, file.path(src, c("hello.txt", "data.csv")))
archive_list(archive_open(out))

# Dated as the files are, in a directory of the archive:
archive_write(out, file.path(src, c("hello.txt", "data.csv")),
  names = c("docs/hello.txt", "docs/data.csv"), mtime = "file")
archive_list(archive_open(out))

# The same files as a tar archive:
tar <- tempfile(fileext = ".tar")
archive_write(tar, file.path(src, c("hello.txt", "data.csv")),
  format = "tar")
archive_list(archive_open(tar))