Temp

Source

Summary

cleanup(tracker)

Cleans up the temporary files tracked by the passed agent pid

mkdir!(options \\ %{}, tracker \\ nil)

Same as mkdir/1, but raises an exception on failure. Otherwise, returns a temporary directory path

mkdir(options \\ %{}, tracker \\ nil)

Returns {:ok, dir_path} where dir_path is the path is the path of the created temporary directory. A tracker agent pid (created by track/1) can be passed as a second argument to keep track of the created directory. Returns {:error, reason} if a failure occurs

open!(options \\ nil, func \\ nil)

Same as open/1, but raises an exception on failure

open(options \\ nil, func \\ nil, tracker \\ nil)

Returns {:ok, fd, file_path} if no callback is passed, or {:ok, file_path} if callback is passed, where fd is the file descriptor of a temporary file and file_path is the path of the temporary file. When no callback is passed, the file descriptor should be closed. A tracker agent pid (created by track/1) can be passed as a second argument to keep track of the created file. Returns {:error, reason} if a failure occurs

path!(options \\ nil)

Same as path/1, but raises an exception on failure. Otherwise, returns a temporary path

path(options \\ nil)

Returns a {:ok, path} where path is a path that can be used freely in the system temporary directory, or {:error, reason} if it fails to get the system temporary directory

track!()

Same as track/1, but raises an exception on failure. Otherwise, returns the tracker pid

track()

Returns an agent pid used to track temporary files

tracked(tracker)

Return the paths currently tracked by the tracker agent

Types

options :: nil | Path.t | %{}

Functions

cleanup(tracker)

Specs:

  • cleanup(pid) :: :ok | {:error, any}

Cleans up the temporary files tracked by the passed agent pid

Source
mkdir(options \\ %{}, tracker \\ nil)

Specs:

Returns {:ok, dir_path} where dir_path is the path is the path of the created temporary directory. A tracker agent pid (created by track/1) can be passed as a second argument to keep track of the created directory. Returns {:error, reason} if a failure occurs.

Source
mkdir!(options \\ %{}, tracker \\ nil)

Specs:

Same as mkdir/1, but raises an exception on failure. Otherwise, returns a temporary directory path.

Source
open(options \\ nil, func \\ nil, tracker \\ nil)

Specs:

Returns {:ok, fd, file_path} if no callback is passed, or {:ok, file_path} if callback is passed, where fd is the file descriptor of a temporary file and file_path is the path of the temporary file. When no callback is passed, the file descriptor should be closed. A tracker agent pid (created by track/1) can be passed as a second argument to keep track of the created file. Returns {:error, reason} if a failure occurs.

Source
open!(options \\ nil, func \\ nil)

Specs:

Same as open/1, but raises an exception on failure.

Source
path(options \\ nil)

Specs:

Returns a {:ok, path} where path is a path that can be used freely in the system temporary directory, or {:error, reason} if it fails to get the system temporary directory.

Source
path!(options \\ nil)

Specs:

Same as path/1, but raises an exception on failure. Otherwise, returns a temporary path.

Source
track()

Specs:

Returns an agent pid used to track temporary files

Source
track!()

Specs:

  • track! :: pid

Same as track/1, but raises an exception on failure. Otherwise, returns the tracker pid.

Source
tracked(tracker)

Specs:

Return the paths currently tracked by the tracker agent.

Source