# `Expresso.PrivateDir`
[🔗](https://github.com/rellen/expresso/blob/main/lib/expresso/private_dir.ex#L1)

Makes a new private directory in the temporary directory of the system

The watch mode and the browser levels of `--check` write a copy of the deck
into such a directory. Many computers have one `/tmp` for all the users, so
each directory obeys these rules:

  * The name is `expresso-<kind>-<random>`, and `<random>` has 26 random
    characters.
  * `File.mkdir/1` makes the directory, so a directory or a symbolic link
    that is already there is an error. The function then tries a different
    name.
  * The mode of the directory is 0700, so no other user can read or write
    its files.

`open!/1` also starts a small `sh` process that removes the directory when
the process that owns it stops, and when the VM stops. Ctrl-C and SIGTERM
halt the VM before an `after` block can run, but the operating system then
closes the pipe to the `sh` process, and that process removes the
directory. `close/1` removes the directory at once.

# `t`

```elixir
@type t() :: %Expresso.PrivateDir{guard: port() | nil, path: Path.t()}
```

A private directory, and the process that removes it

# `close`

```elixir
@spec close(t()) :: :ok
```

Remove the directory, and stop its `sh` process

# `create!`

```elixir
@spec create!(String.t(), Path.t(), (-&gt; String.t())) :: Path.t()
```

Make a new directory with the mode 0700 in `parent`, and return its path

`random` returns the random part of each name that the function tries. The
tests give a different function.

# `open!`

```elixir
@spec open!(String.t()) :: t()
```

Make a new private directory, and remove it when the calling process stops

The function raises when it cannot make the directory.

---

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