Function atomicFile [src]
Directly access the .file field, and then call AtomicFile.finish to
atomically replace dest_path with contents.
Always call AtomicFile.deinit to clean up, regardless of whether
AtomicFile.finish succeeded. dest_path must remain valid until
AtomicFile.deinit is called.
On Windows, dest_path should be encoded as WTF-8.
On WASI, dest_path should be encoded as valid UTF-8.
On other platforms, dest_path is an opaque sequence of bytes with no particular encoding.
Prototype
pub fn atomicFile(self: Dir, dest_path: []const u8, options: AtomicFileOptions) !AtomicFile
Parameters
self: Dir
dest_path: []const u8
options: AtomicFileOptions
Source
pub fn atomicFile(self: Dir, dest_path: []const u8, options: AtomicFileOptions) !AtomicFile {
if (fs.path.dirname(dest_path)) |dirname| {
const dir = if (options.make_path)
try self.makeOpenPath(dirname, .{})
else
try self.openDir(dirname, .{});
return AtomicFile.init(fs.path.basename(dest_path), options.mode, dir, true);
} else {
return AtomicFile.init(dest_path, options.mode, self, false);
}
}