Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

std/archive/mod.ts

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
import * as mod from "https://deno.land/std@0.220.1/archive/mod.ts";

Tar is a utility for collecting multiple files (or any arbitrary data) into one archive file, while untar is the inverse utility to extract the files from an archive. Files are not compressed, only collected into the archive.

import { Tar } from "https://deno.land/std@0.220.1/archive/tar.ts";
import { Buffer } from "https://deno.land/std@0.220.1/io/buffer.ts";
import { copy } from "https://deno.land/std@0.220.1/io/copy.ts";

const tar = new Tar();

// Now that we've created our tar, let's add some files to it:

const content = new TextEncoder().encode("Some arbitrary content");
await tar.append("deno.txt", {
  reader: new Buffer(content),
  contentSize: content.byteLength,
});

// This file is sourced from the filesystem (and renamed in the archive)
await tar.append("filename_in_archive.txt", {
  filePath: "./filename_on_filesystem.txt",
});

// Now let's write the tar (with it's two files) to the filesystem
// use tar.getReader() to read the contents.

const writer = await Deno.open("./out.tar", { write: true, create: true });
await copy(tar.getReader(), writer);
writer.close();

Classes

Overview

A class to create 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.

Contains tar header metadata and a reader to the entry's body.

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.

Interfaces

Base interface for TarDataWithSource.

Tar data interface for Tar.data.

Tar entry

Base interface for TarMeta

Base interface for TarMetaWithLinkName.

Extend TarMeta with the linkName property so that readers can access symbolic link values without polluting the world of archive writers.

Options for Tar.append.

Type Aliases

Tar header with raw, unprocessed bytes as values.