View Source AtomicWrites.AtomicFile (atomic_writes v1.0.0)

Given a file path (and other optional config), AtomicFile provides a write/2 method for serially and atomically writing to the given path.

Summary

Functions

Returns a specification to start this module under a supervisor.

Callback implementation for GenServer.init/1.

  • :path (String.t/0) - Required. Path to the final file that is atomically written.

Atomically write to the path managed by the process.

Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Callback implementation for GenServer.init/1.

  • :path (String.t/0) - Required. Path to the final file that is atomically written.

  • :overwrite? (boolean/0) - Overwrite the target file if it already exists? The default value is true.

  • :tmp_dir (String.t/0) - Directory in which the temporary files are written. The default value is ".".

@spec write(pid(), iodata()) :: :ok | {:error, atom()}

Atomically write to the path managed by the process.