Skip to main content

write_atomic

Function write_atomic 

Source
pub fn write_atomic(
    target: &Path,
    contents: &[u8],
    mode: Option<u32>,
) -> Result<()>
Expand description

Writes contents to target by creating <target>.tmp on exclusive terms (see open_temporary), fsyncing it, and renaming it over target — the rename is atomic, so a reader of target never observes a partially written file. Leaves <target>.tmp behind on a write/fsync failure; the next call clears it as ordinary residue.