# `Sys.Tmp`
[🔗](https://github.com/harmont-dev/hyper/blob/main/lib/sys/tmp.ex#L1)

Temporary file/directory helpers.

Names carry the caller's `prefix` (so leaked entries are identifiable) plus
a cryptographically random component, and creation is exclusive (`O_EXCL` /
plain `mkdir`) with retry-on-collision — so concurrent callers, other OS
processes, VM restarts, and pre-planted paths (symlinks in a world-writable
tmp dir) can never hand a caller a path someone else controls.

# `with_tempdir`

```elixir
@spec with_tempdir(String.t(), (Path.t() -&gt; result)) :: result when result: var
```

Create a fresh temporary directory, pass its path to `fun`, and remove it
(recursively) afterward - even if `fun` raises. Returns whatever `fun`
returns.

# `with_tmpfile`

```elixir
@spec with_tmpfile(String.t(), (Path.t() -&gt; result)) :: result when result: var
```

Create a fresh empty temporary file, pass its path to `fun`, and remove it
afterward - even if `fun` raises. Returns whatever `fun` returns.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
