import { Untar } from "https://deno.land/std@0.194.0/archive/untar.ts";
A class to extract a tar archive
Examples
Example 1
Example 1
import { Untar } from "https://deno.land/std@0.194.0/archive/untar.ts";
import { ensureFile } from "https://deno.land/std@0.194.0/fs/ensure_file.ts";
import { ensureDir } from "https://deno.land/std@0.194.0/fs/ensure_dir.ts";
import { copy } from "https://deno.land/std@0.194.0/streams/copy.ts";
const 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);
const file = await Deno.open(entry.fileName, { write: true });
// <entry> is a reader.
await copy(entry, file);
}
reader.close();
Constructors
new
Untar(reader: Reader)Properties
reader: Reader
Methods
[Symbol.asyncIterator](): AsyncIterableIterator<TarEntry>