Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Treatment untar

fs/archive::untar


Inputs

⇥ data: Stream<byte>
⇥ filesystem: Block<FileSystem> (fs/filesystem::FileSystem)
⇥ path: Block<string>

Outputs

↦ completed: Block<void>
↦ errors: Stream<string>
↦ failed: Block<void>
↦ finished: Block<void>


Extract an archive.

The tar archive received through data is extracted to the directory path of filesystem, its entries being written while they come. path must not exist: it is created, so that an archive never mixes with existing content.

Files, directories and symbolic links are extracted, with their mode and modification time, those of directories once their content is written. Links are made as written, and never followed. An entry with .. or an absolute path, or going through a link of the archive, fails the extraction, as do hard links and other kinds of entries: nothing is ever written out of path.

Once the archive is extracted, completed is emitted. If it fails, failed is emitted and errors contains the reason, what was extracted being left as is: extract into a directory of your own, and remove it on failure. finished is emitted in every case.

graph LR
     T("untar()")
     F["〈🟨〉"] -->|filesystem| T
     P["〈🟨〉"] -->|path| T
     B["… 🟦 🟦 🟦"] -->|data| T

     T -->|completed| C["〈🟩〉"]
     T -->|failed| E["〈🟥〉"]

     style F fill:#ffffff,stroke:#ffffff
     style P fill:#ffffff,stroke:#ffffff
     style B fill:#ffffff,stroke:#ffffff
     style C fill:#ffffff,stroke:#ffffff
     style E fill:#ffffff,stroke:#ffffff