Atomically materializes the file into place, replacing any file that already exists there.
Calling this function requires setting CreateFileAtomicOptions.replace to
true.
On Windows, this function introduces a period of time where some file
system operations on the destination file will result in
error.AccessDenied, including rename operations (such as the one used in
this function).
pub fn replace(af: *Atomic, io: Io) ReplaceError!void
pub fn replace(af: *Atomic, io: Io) ReplaceError!void {
assert(af.file_exists); // Wrong value for `CreateFileAtomicOptions.replace`.
if (af.file_open) {
af.file.close(io);
af.file_open = false;
}
const tmp_sub_path = std.fmt.hex(af.file_basename_hex);
try af.dir.rename(&tmp_sub_path, af.dir, af.dest_sub_path, io);
af.file_exists = false;
}