Skip to main content

write_atomically

Function write_atomically 

Source
pub fn write_atomically(path: &Path, content: &[u8]) -> Result<()>
Expand description

Write content to path atomically.

The new content lands in a temp file next to the target and is renamed into place, so the target is only ever the complete old or complete new file. The original file’s permissions are preserved on the replacement, and symlinks are written through (the resolved real file is replaced, the link is kept), matching the behavior of a plain fs::write.

On any failure the temp file is removed and the original target is left exactly as it was.