Skip to main content

atomic_write

Function atomic_write 

Source
pub fn atomic_write(path: &Path, contents: &str) -> Result<()>
Expand description

Write contents to a file atomically using write-to-temp + rename.

Writes to a temporary file in the same directory as path, then renames it to the target. rename() is atomic on POSIX when source and destination are on the same filesystem (guaranteed here since we use the same directory). The temp file is cleaned up on error.