Skip to main content
Home
This package has been archived, and as such it is read-only.

@std/archive@0.225.4
Built and signed on GitHub Actions

DEPRECATED: Use @std/tar

This package works with Deno
This package works with Deno
JSR Score
94%
Published
9 months ago (0.225.4)
class Untar
Unstable
Deprecated

Use @std/tar instead. @std/archive will be removed in the future.

Supported file formats

Only the ustar file format is supported. This is the most common format. The pax file format may also be read, but additional features, such as longer filenames may be ignored.

Usage

The workflow is to create a Untar instance referencing the source of the tar file. You can then use the untar reference to extract files one at a time. See the worked example below for details.

Understanding compression

A tar archive may be compressed, often identified by the .tar.gz extension. This utility does not support decompression which must be done before extracting the files.

Overview

A class to extract from a tar archive. Tar archives allow for storing multiple files in a single file (called an archive, or sometimes a tarball). These archives typically have the '.tar' extension.

Examples

Usage

import { Untar } from "@std/archive/untar";
import { ensureFile } from "@std/fs/ensure-file";
import { ensureDir } from "@std/fs/ensure-dir";
import { copy } from "@std/io/copy";

using reader = await Deno.open("./out.tar", { read: true });
const untar = new Untar(reader);

for await (const entry of untar) {
  console.log(entry); // metadata

  if (entry.type === "directory") {
    await ensureDir(entry.fileName);
    continue;
  }

  await ensureFile(entry.fileName);
  using file = await Deno.open(entry.fileName, { write: true });
  // <entry> is a reader.
  await copy(entry, file);
}

Constructors

new
Untar(reader: Reader)

Constructs a new instance.

Methods

[Symbol.asyncIterator](): AsyncIterableIterator<TarEntry>

Iterate over all entries of the tar archive.

Extract the next entry of the tar archive.

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@std/archive

Import symbol

import { Untar } from "@std/archive";
or

Import directly with a jsr specifier

import { Untar } from "jsr:@std/archive";