Skip to main content

write_igvm_file_atomic

Function write_igvm_file_atomic 

Source
pub(crate) fn write_igvm_file_atomic(
    output: &Path,
    data: &[u8],
    log_message: &str,
) -> Result<()>
Expand description

Atomically write data to output: write to a sibling temp file, then rename it into place. This prevents a crash or interruption during the write from corrupting the output (which may be the same file as the input for in-place edits). Same-volume renames are atomic on both POSIX and Windows (std::fs::rename uses MoveFileExW with MOVEFILE_REPLACE_EXISTING). log_message is emitted before the write.