archive_list() returns one row per member of the archive, in the order
of the archive's central directory, duplicates included.
Arguments
- z
A handle from
archive_open().
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, aPOSIXctin UTC.type:"file","directory"or"symlink"; in a tar archive also"hardlink", and"other"for a device, a FIFO or another special member.encrypted:TRUEfor a member encrypted with ZipCrypto, strong encryption or WinZip AES.
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.
Conditions
Every refusal is an error of class zuarchive_error and a subclass:
zuarchive_error_limit: a limit is exceeded; the condition'slimitfield 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.
Examples
z <- archive_open(system.file("extdata", "hello.zip", package = "zuarchive"))
archive_list(z)
#> name size compressed method mtime type encrypted
#> 1 hello.txt 5 5 stored 1980-01-01 file FALSE