7 tar File Extraction

▼ |  | File: Racket File Format Libraries

1 | Convertible: Data-Conversion Protocol
2 | gzip Compression and File Creation
3 | gzip Decompression
4 | zip File Creation
5 | zip File Extraction
6 | tar File Creation
7 | tar File Extraction
8 | tar+gzip File Extraction
9 | MD5 Message Digest
10 | SHA1 Message Digest
11 | GIF File Writing
12 | ICO File Reading and Writing
13 | Windows Registry
| Bibliography
| Index

On this page:

untar

top ← prev up next →

### 7`` tar File Extraction

(require file/untar)

The file/untar library provides a function to extract items from a TAR/USTAR archive.

> > procedure
> > (untar |  | in |  |  |  |
> > | [ | #:dest dest-path |  |  |  |
> > |  | #:strip-count strip-count |  |  |  |
> > |  | #:filter filter-proc]) |  | → |  | void?
> in : (or/c path-string? input-port?)
> dest-path : (or/c path-string? #f) = #f
> strip-count : exact-nonnegative-integer? = 0
> | filter-proc |  | : |  |
> (path? (or/c path? #f)
> symbol? exact-integer? (or/c path? #f)
> exact-nonnegative-integer?
> exact-nonnegative-integer?
> . -> . any/c)
> |  |  | = |  | (lambda args #t)

Extracts TAR/USTAR content from in.

If dest-path is not #f, every path in the archive is prefixed to determine the destination path of the extracted item.

If strip-count is positive, then strip-count path elements are removed from the item path from the archive (before prefixing the path with dest-path); if the item’s path contains strip-count elements, then it is not extracted.

For each item in the archive, filter-proc is applied to

- the item’s path as it appears in the archive;

- a destination path that is based on the path in the archive, strip-count, and dest-path–which can be #f if the item’s path does not have strip-count or more elements;

- a symbol representing the item’s type—'file, 'dir, 'link, 'hard-link, 'character-special, 'block-special, 'fifo, 'contiguous-file, 'extended-header, 'extended-header-for-next, or 'unknown—where only 'file, 'dir, or 'link can be unpacked by untar;

- an exact integer representing the item’s size;

- a target path for a 'link type or #f for any other type;

- an integer representing the item’s modification date; and

- an integer representing the item’s permissions

If the result of filter-proc is #f, then the item is not unpacked.

top ← prev up next →