DoxigAlpha

renameIntoPlace

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).

Function parameters

Parameters

#
af:*AtomicFile

Note that the `Dir.atomicFile` API may be more handy than this lower-level function.

Functions

#
init
Note that the `Dir.atomicFile` API may be more handy than this lower-level function.
deinit
Always call deinit, even after a successful finish().
renameIntoPlace
On Windows, this function introduces a period of time where some file
finish
Combination of `flush` followed by `renameIntoPlace`.

Error sets in this namespace

Error Sets

#

Source

Implementation

#
pub fn renameIntoPlace(af: *AtomicFile) RenameIntoPlaceError!void {
    assert(af.file_exists);
    if (af.file_open) {
        af.file_writer.file.close();
        af.file_open = false;
    }
    const tmp_sub_path = std.fmt.hex(af.random_integer);
    try posix.renameat(af.dir.fd, &tmp_sub_path, af.dir.fd, af.dest_basename);
    af.file_exists = false;
}