You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/functions.inc.html
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -126,10 +126,10 @@ <h1 id="functions-file-directory">File and Directory <a class="section-link" hre
126
126
<tr><td><code>zipExtract</code></td><td>Extract an entire archive. Options dict is required; defaults: <code>overwrite=false</code>, <code>skipExisting=false</code> (mutually exclusive), <code>stripComponents=0</code>, <code>pattern=""</code> (glob matched before stripping), <code>preservePermissions=true</code>, <code>maxBytes=0</code> (0 = unlimited; a cap on the total uncompressed bytes written, guarding against decompression bombs). Destination is created if missing.</td><td><code>(<spanclass="sig-type sig-type-path">path</span>:zipPath <spanclass="sig-type sig-type-path">path</span>:destDir <spanclass="sig-type sig-type-dict">dict</span>:options -- )</code></td></tr>
127
127
<tr><td><code>zipExtractEntry</code></td><td>Extract a single entry (file or directory subtree) to a destination path. Options dict is required; defaults: <code>overwrite=false</code>, <code>skipExisting=false</code> (mutually exclusive), <code>preservePermissions=true</code>, <code>mkdirs=true</code> (create parent directories when needed), <code>maxBytes=0</code> (0 = unlimited uncompressed-byte cap).</td><td><code>(<spanclass="sig-type sig-type-path">path</span>:zipPath <spanclass="sig-type sig-type-str">str</span>:entry <spanclass="sig-type sig-type-path">path</span>:dest <spanclass="sig-type sig-type-dict">dict</span>:options -- )</code></td></tr>
128
128
<tr><td><code>zipRead</code></td><td>Read an entry’s bytes directly into the stack without writing to disk. Returns <code>none</code> when the entry does not exist.</td><td><code>(<spanclass="sig-type sig-type-path">path</span>:zipPath <spanclass="sig-type sig-type-str">str</span>:entry -- <spanclass="sig-type sig-type-maybe">Maybe</span>[<spanclass="sig-type sig-type-binary">binary</span>])</code></td></tr>
129
-
<tr><tdcolspan="3"><em>Tar functions mirror the <code>zip*</code> surface (same argument order and option dicts). Compression is chosen from the destination extension when writing (<code>.tar.gz</code> / <code>.tgz</code> → gzip, <code>.tar</code> → uncompressed) and auto-detected from the gzip magic bytes when reading. Symlinks are preserved: packed as symlink entries and recreated on extraction (with an escape guard); hard links and device nodes are rejected.</em></td></tr>
130
-
<tr><td><code>tarDirInc</code></td><td>Create/overwrite a <code>.tar</code> / <code>.tar.gz</code> from a directory; the archive root contains the directory’s contents (no parent folder).</td><td><code>(<spanclass="sig-type sig-type-path">path</span>:sourceDir <spanclass="sig-type sig-type-path">path</span>:tarPath -- )</code></td></tr>
131
-
<tr><td><code>tarDirExc</code></td><td>Create/overwrite a <code>.tar</code> / <code>.tar.gz</code> that includes the source directory itself at the archive root (entries are prefixed with the directory name).</td><td><code>(<spanclass="sig-type sig-type-path">path</span>:sourceDir <spanclass="sig-type sig-type-path">path</span>:tarPath -- )</code></td></tr>
132
-
<tr><td><code>tarPack</code></td><td>Create/overwrite a <code>.tar</code> / <code>.tar.gz</code> by packing a list of entries. Each entry is either a bare string/path (the file or directory to add, keeping its base name and mode) or a dictionary requiring <code>path</code>; in the dictionary form <code>archivePath</code> (override the in-archive name) and <code>mode</code> are optional. <code>mode</code> is a Go <ahref="https://pkg.go.dev/io/fs#FileMode" target="_blank" rel="noopener noreferrer"><code>os.FileMode</code></a>; write it with an octal literal, e.g. <code>0o644</code> (<code>rw-r--r--</code>), <code>0o755</code> (<code>rwxr-xr-x</code>), <code>0o600</code>. If <code>mode</code> is omitted, the entry keeps the source file’s own mode.</td><td><code>([<spanclass="sig-type sig-type-str">str</span>|<spanclass="sig-type sig-type-path">path</span>|<spanclass="sig-type sig-type-dict">dict</span>] <spanclass="sig-type sig-type-path">path</span>:tarPath -- )</code></td></tr>
129
+
<tr><tdcolspan="3"><em>Tar functions mirror the <code>zip*</code> surface (same argument order and option dicts). Compression is chosen from the destination extension when writing (<code>.tar.gz</code> / <code>.tgz</code> → gzip, <code>.tar</code> → uncompressed) and auto-detected from the gzip magic bytes when reading. The write destination may also be a dictionary <code>{path: str|path, compress?: bool}</code>, where <code>compress</code> overrides the extension inference in either direction — useful for destinations without a meaningful extension (e.g. <code>redo</code>’s <code>$3</code> temp files). Symlinks are preserved: packed as symlink entries and recreated on extraction (with an escape guard); hard links and device nodes are rejected.</em></td></tr>
130
+
<tr><td><code>tarDirInc</code></td><td>Create/overwrite a <code>.tar</code> / <code>.tar.gz</code> from a directory; the archive root contains the directory’s contents (no parent folder). The destination may be a dictionary <code>{path, compress?}</code> to force compression on or off.</td><td><code>(<spanclass="sig-type sig-type-path">path</span>:sourceDir <spanclass="sig-type sig-type-path">path</span>|<spanclass="sig-type sig-type-dict">dict</span>:dest -- )</code></td></tr>
131
+
<tr><td><code>tarDirExc</code></td><td>Create/overwrite a <code>.tar</code> / <code>.tar.gz</code> that includes the source directory itself at the archive root (entries are prefixed with the directory name). The destination may be a dictionary <code>{path, compress?}</code> to force compression on or off.</td><td><code>(<spanclass="sig-type sig-type-path">path</span>:sourceDir <spanclass="sig-type sig-type-path">path</span>|<spanclass="sig-type sig-type-dict">dict</span>:dest -- )</code></td></tr>
132
+
<tr><td><code>tarPack</code></td><td>Create/overwrite a <code>.tar</code> / <code>.tar.gz</code> by packing a list of entries. Each entry is either a bare string/path (the file or directory to add, keeping its base name and mode) or a dictionary requiring <code>path</code>; in the dictionary form <code>archivePath</code> (override the in-archive name) and <code>mode</code> are optional. <code>mode</code> is a Go <ahref="https://pkg.go.dev/io/fs#FileMode" target="_blank" rel="noopener noreferrer"><code>os.FileMode</code></a>; write it with an octal literal, e.g. <code>0o644</code> (<code>rw-r--r--</code>), <code>0o755</code> (<code>rwxr-xr-x</code>), <code>0o600</code>. If <code>mode</code> is omitted, the entry keeps the source file’s own mode. The destination may be a dictionary <code>{path, compress?}</code> to force compression on or off.</td><td><code>([<spanclass="sig-type sig-type-str">str</span>|<spanclass="sig-type sig-type-path">path</span>|<spanclass="sig-type sig-type-dict">dict</span>] <spanclass="sig-type sig-type-path">path</span>|<spanclass="sig-type sig-type-dict">dict</span>:dest -- )</code></td></tr>
133
133
<tr><td><code>tarList</code></td><td>List archive entries as dictionaries with keys: <code>name</code> (string, forward-slash paths, directories end with <code>/</code>), <code>compressedSize</code> and <code>uncompressedSize</code> (int bytes; equal, since tar has no per-entry compressed size), <code>isDir</code> (bool), <code>perm</code> (int POSIX permission bits), <code>executable</code> (bool), <code>modified</code> (datetime), <code>type</code> (<code>"file"</code>/<code>"dir"</code>/<code>"symlink"</code>), and <code>linkTarget</code> (symlink target, empty otherwise).</td><td><code>(<spanclass="sig-type sig-type-path">path</span> -- [<spanclass="sig-type sig-type-dict">dict</span>])</code></td></tr>
134
134
<tr><td><code>tarExtract</code></td><td>Extract an entire archive. Options dict is required; defaults: <code>overwrite=false</code>, <code>skipExisting=false</code> (mutually exclusive), <code>stripComponents=0</code>, <code>pattern=""</code> (glob matched before stripping), <code>preservePermissions=true</code>, <code>maxBytes=0</code> (0 = unlimited; a cap on the total uncompressed bytes written, guarding against decompression bombs). Destination is created if missing.</td><td><code>(<spanclass="sig-type sig-type-path">path</span>:tarPath <spanclass="sig-type sig-type-path">path</span>:destDir <spanclass="sig-type sig-type-dict">dict</span>:options -- )</code></td></tr>
135
135
<tr><td><code>tarExtractEntry</code></td><td>Extract a single entry (file or directory subtree) to a destination path. Options dict is required; defaults: <code>overwrite=false</code>, <code>skipExisting=false</code> (mutually exclusive), <code>preservePermissions=true</code>, <code>mkdirs=true</code> (create parent directories when needed), <code>maxBytes=0</code> (0 = unlimited uncompressed-byte cap).</td><td><code>(<spanclass="sig-type sig-type-path">path</span>:tarPath <spanclass="sig-type sig-type-str">str</span>:entry <spanclass="sig-type sig-type-path">path</span>:dest <spanclass="sig-type sig-type-dict">dict</span>:options -- )</code></td></tr>
- Symlinks are preserved: `tarPack`/`tarDir*` store symlinks as symlink entries,
1488
1493
and `tarExtract`/`tarExtractEntry` recreate them (rejecting any whose target
1489
1494
would escape the destination directory). Extraction also refuses to write
@@ -1495,8 +1500,8 @@ bytes; `0` = unlimited) to guard against decompression bombs, and packing never
1495
1500
follows a source symlink, so a symlink loop or a link to `/dev/zero` cannot hang
1496
1501
or inflate the archive.
1497
1502
1498
-
-`tarDirInc`: Create/overwrite a `.tar`/`.tar.gz` from a directory; the archive root contains the directory's contents (no parent folder). `(path:sourceDir path:tarPath -- )`
1499
-
-`tarDirExc`: Create/overwrite a `.tar`/`.tar.gz` that includes the source directory itself at the archive root (entries are prefixed with the directory name). `(path:sourceDir path:tarPath -- )`
1503
+
-`tarDirInc`: Create/overwrite a `.tar`/`.tar.gz` from a directory; the archive root contains the directory's contents (no parent folder). `(str | path str | path | {path: str | path, compress?: bool} -- )`
1504
+
-`tarDirExc`: Create/overwrite a `.tar`/`.tar.gz` that includes the source directory itself at the archive root (entries are prefixed with the directory name). `(str | path str | path | {path: str | path, compress?: bool} -- )`
1500
1505
-`tarPack`: Create/overwrite a `.tar`/`.tar.gz` by packing a list of entries.
1501
1506
Each entry is either a bare string/path (the file or directory to add,
1502
1507
keeping its base name and mode) or a dictionary.
@@ -1505,7 +1510,7 @@ or inflate the archive.
1505
1510
`mode` is a Go `os.FileMode`; write it with an octal literal,
1506
1511
e.g. `0o644` (`rw-r--r--`), `0o755` (`rwxr-xr-x`), `0o600`.
1507
1512
If `mode` is omitted, the entry keeps the source file's own mode.
-`tarList`: List archive entries as dictionaries with keys: `name` (string, forward-slash paths, directories end with `/`), `compressedSize` and `uncompressedSize` (int bytes; equal, since tar has no per-entry compressed size), `isDir` (bool), `perm` (int POSIX permission bits), `executable` (bool), `modified` (datetime from the archive entry), `type` (`"file"`/`"dir"`/`"symlink"`), and `linkTarget` (symlink target, empty otherwise). `(path -- [dict])`
1510
1515
-`tarExtract`: Extract an entire archive. Options dict is required; defaults: `overwrite=false`, `skipExisting=false` (mutually exclusive), `stripComponents=0`, `pattern=""` (glob matched before stripping), `preservePermissions=true`, `maxBytes=0` (0 = unlimited; caps the total uncompressed bytes written to guard against decompression bombs). Destination is created if missing. `(path:tarPath path:destDir dict:options -- )`
1511
1516
-`tarExtractEntry`: Extract a single entry (file or directory subtree) to a destination path. Options dict is required; defaults: `overwrite=false`, `skipExisting=false` (mutually exclusive), `preservePermissions=true`, `mkdirs=true`, `maxBytes=0` (0 = unlimited uncompressed-byte cap). `(path:tarPath str:entry path:dest dict:options -- )`
0 commit comments