1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
x1 x1 x1 x1 x1 x2 x1 x1 x1 x1 x2 x1 x1 x1 x1 x2 x1 |
/**
* 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.
*
* ```ts ignore
* import { Tar } from "@std/archive/tar";
* import { Buffer } from "@std/io/buffer";
* import { copy } from "@std/io/copy";
*
* 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 its 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();
* ```
*
* @deprecated Use {@linkcode https://jsr.io/@std/tar | @std/tar} instead.
* `@std/archive` will be removed in the future.
*
* @experimental
* @module
*/
import type { TarInfo as _interface_TarInfo } from "jsr:@std/[email protected]"
/**
* Base interface for {@linkcode TarMeta}.
*
* @deprecated Use {@linkcode https://jsr.io/@std/tar | @std/tar} instead.
* `@std/archive` will be removed in the future.
*
* @experimental
*/
interface TarInfo extends _interface_TarInfo {}
export type { TarInfo }
import type { TarMeta as _interface_TarMeta } from "jsr:@std/[email protected]"
/**
* Base interface for {@linkcode TarMetaWithLinkName}.
*
* @deprecated Use {@linkcode https://jsr.io/@std/tar | @std/tar} instead.
* `@std/archive` will be removed in the future.
*
* @experimental
*/
interface TarMeta extends _interface_TarMeta {}
export type { TarMeta }
import type { TarOptions as _interface_TarOptions } from "jsr:@std/[email protected]"
/**
* Options for {@linkcode Tar.append}.
*
* @deprecated Use {@linkcode https://jsr.io/@std/tar | @std/tar} instead.
* `@std/archive` will be removed in the future.
*
* @experimental
*/
interface TarOptions extends _interface_TarOptions {}
export type { TarOptions }
import type { TarData as _interface_TarData } from "jsr:@std/[email protected]"
/**
* Base interface for {@linkcode TarDataWithSource}.
*
* @deprecated Use {@linkcode https://jsr.io/@std/tar | @std/tar} instead.
* `@std/archive` will be removed in the future.
*
* @experimental
*/
interface TarData extends _interface_TarData {}
export type { TarData }
import type { TarDataWithSource as _interface_TarDataWithSource } from "jsr:@std/[email protected]"
/**
* Tar data interface for {@linkcode Tar.data}.
*
* @deprecated Use {@linkcode https://jsr.io/@std/tar | @std/tar} instead.
* `@std/archive` will be removed in the future.
*
* @experimental
*/
interface TarDataWithSource extends _interface_TarDataWithSource {}
export type { TarDataWithSource }
import { Tar as _class_Tar } from "jsr:@std/[email protected]"
/**
* ### 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.
*
* @deprecated Use {@linkcode https://jsr.io/@std/tar | @std/tar} instead.
* `@std/archive` will be removed in the future.
*
* ### Usage
* The workflow is to create a Tar instance, append files to it, and then write the
* tar archive to the filesystem (or other output stream). See the worked example
* below for details.
*
* ### Compression
* Tar archives are not compressed by default. If you want to compress the archive,
* you may compress the tar archive after creation, but this capability is not provided
* here.
*
* ### File format and limitations
*
* The ustar file format is used for creating the archive file.
* While this format is compatible with most tar readers,
* the format has several limitations, including:
* * Files must be smaller than 8GiB
* * Filenames (including path) must be shorter than 256 characters
* * Filenames (including path) cannot contain non-ASCII characters
* * Sparse files are not supported
*
* @example Usage
* ```ts ignore
* import { Tar } from "@std/archive/tar";
* import { Buffer } from "@std/io/buffer";
* import { copy } from "@std/io/copy";
*
* 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 its 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();
* ```
*
* @experimental
*/
class Tar extends _class_Tar {}
export { Tar }
import type { Reader as _interface_Reader } from "jsr:@std/[email protected]"
/**
* An abstract interface which when implemented provides an interface to read
* bytes into an array buffer asynchronously.
*/
interface Reader extends _interface_Reader {}
export type { Reader }
import type { Seeker as _interface_Seeker } from "jsr:@std/[email protected]"
/**
* An abstract interface which when implemented provides an interface to seek
* within an open file/resource asynchronously.
*/
interface Seeker extends _interface_Seeker {}
export type { Seeker }
import type { TarMetaWithLinkName as _interface_TarMetaWithLinkName } from "jsr:@std/[email protected]"
/**
* Extend TarMeta with the `linkName` property so that readers can access
* symbolic link values without polluting the world of archive writers.
*
* @deprecated Use {@linkcode https://jsr.io/@std/tar | @std/tar} instead.
* `@std/archive` will be removed in the future.
*
* @experimental
*/
interface TarMetaWithLinkName extends _interface_TarMetaWithLinkName {}
export type { TarMetaWithLinkName }
import type { TarHeader as _typeAlias_TarHeader } from "jsr:@std/[email protected]"
/**
* Tar header with raw, unprocessed bytes as values.
*
* @deprecated Use {@linkcode https://jsr.io/@std/tar | @std/tar} instead.
* `@std/archive` will be removed in the future.
*
* @experimental
*/
type TarHeader = _typeAlias_TarHeader
export type { TarHeader }
import { TarEntry as _class_TarEntry } from "jsr:@std/[email protected]"
/**
* Contains tar header metadata and a reader to the entry's body.
*
* @deprecated Use {@linkcode https://jsr.io/@std/tar | @std/tar} instead.
* `@std/archive` will be removed in the future.
*
* @experimental
* @example Usage
* ```ts ignore
* import { TarEntry } from "@std/archive/untar";
* import { Buffer } from "@std/io/buffer";
*
* const content = new TextEncoder().encode("hello tar world!");
* const reader = new Buffer(content);
* const tarMeta = {
* fileName: "archive/",
* fileSize: 0,
* fileMode: 509,
* mtime: 1591800767,
* uid: 1001,
* gid: 1001,
* owner: "deno",
* group: "deno",
* type: "directory",
* };
* const tarEntry: TarEntry = new TarEntry(tarMeta, reader);
* ```
*/
class TarEntry extends _class_TarEntry {}
export { TarEntry }
import { Untar as _class_Untar } from "jsr:@std/[email protected]"
/**
* ### 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.
*
* @deprecated Use {@linkcode https://jsr.io/@std/tar | @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.
*
* @example Usage
* ```ts ignore
* 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);
* }
* ```
*
* @experimental
*/
class Untar extends _class_Untar {}
export { Untar }
|