View Source AtomicWrites (atomic_writes v1.1.0)

Performs atomic file writes.

Options

  • :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 ".".

LWW Atomic Writes

AtomicWrites.write("Atomically written content.", path: "example.txt")

FWW Atomic Writes

AtomicWrites.write("Atomically written content.", path: "example.txt", overwrite?: false)

Serialized Atomic Writes

alias AtomicWrites.AtomicFile

{:ok, pid} = AtomicFile.start_link(path: "example.txt")
AtomicFile.write(pid, "Serialized, atomically written content.")

Installation

The package can be installed by adding atomic_writes to your list of dependencies in mix.exs:

def deps do
[
  {:atomic_writes, "~> 1.0"}
]
end

License

AtomicWrites is released under the Apache License 2.0.

About

This package was written by Elliot Jackson.

Summary

Functions

Atomically write to the path.

Functions

@spec write(iodata(), Keyword.t()) :: :ok | {:error, atom()}

Atomically write to the path.