pub fn write_atomic(path: &Utf8Path, bytes: &[u8]) -> Result<()>Expand description
Write a file through a sibling temporary file and a rename, creating its parent directories.
The scratch file is created exclusively, so a path that already exists there, a symlink to somewhere else included, refuses the write rather than being followed or truncated. A failure partway leaves the destination as it was rather than half-written, and an interruption leaves either the old bytes or the new.
ยงErrors
Any I/O error creating directories, creating or writing the scratch
file, or renaming it into place. A scratch path that already exists is
std::io::ErrorKind::AlreadyExists.