import * as mod from "https://deno.land/std@0.224.0/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.224.0/archive/tar.ts";
import { Buffer } from "https://deno.land/std@0.224.0/io/buffer.ts";
import { copy } from "https://deno.land/std@0.224.0/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
c Tar | OverviewA 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. | |
OverviewA 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 | |
Tar data interface for | |
Tar entry | |
Base interface for | |
Base interface for | |
Extend TarMeta with the | |
Options for |
Type Aliases
Tar header with raw, unprocessed bytes as values. |