Skip to content

list ​

list lee las entradas de un archivo ZIP, TAR o TAR.GZ sin escribir nada en disco. El formato se identifica por el contenido, nunca por el nombre del archivo.

Úselo para inspeccionar un archivo no confiable antes de extraerlo: las entradas que unpack rechazaría, como los enlaces, aparecen con su tipo, y los nombres se informan exactamente como el archivo los guarda.

Firmalist(archive: string, options?: UnpackOptions): Promise<Result<ArchiveEntry[], ArchiveError>>

Ejemplo mínimo ​

tyrus
import { ArchiveEntry, ArchiveError, list } from "tyrus:archive";

async function inspect(): Promise<Result<void, ArchiveError>> {
    const entries: ArchiveEntry[] = await list("./upload.zip")?;
    print(entries.length); // 3
    print(entries[0].name); // report.pdf
    return Ok();
}

Todas las opciones ​

tyrus
import { ArchiveEntry, ArchiveEntryKind, ArchiveError, UnpackOptions, list } from "tyrus:archive";

async function inspect(): Promise<Result<void, ArchiveError>> {
    const entries: ArchiveEntry[] = await list("./upload.zip", {
        maxEntries: 1_000, // reject archives with more entries; default 100000
        timeoutMs: 30_000, // give up after this many milliseconds; default 600000 (10 minutes)
    })?;
    const first: ArchiveEntry = entries[0];
    print(first.name); // report.pdf
    print(first.kind === ArchiveEntryKind.File); // true
    print(first.size); // 20480
    print(first.compressedSize ?? 0); // 18311
    return Ok();
}

list solo lee maxEntries y timeoutMs de UnpackOptions; las demás opciones se aplican a la extracción. Un archivo con más entradas falla con ERR_ARCHIVE_ENTRY_LIMIT, y un archivo ZIP falla antes de leer su tabla de entradas.