Expand description
Atomic file writes.
Plain fs::write truncates the target to zero length and then writes the
new contents in place. A crash / kill / disk-full between those two steps
leaves the file empty or half-written โ catastrophic for session,
checkpoint, and plugin-lockfile state that is rewritten in full on every
save. write_atomic writes to a temp sibling, fsyncs it, then renames over
the target, so a reader always sees either the old complete file or the new
complete file.
Functionsยง
- write_
atomic - Write
bytestopathatomically: temp file in the same directory โsync_allโ rename over the destination. The rename is atomic on the same filesystem (and replaces an existing target on both Unix and Windows).