deinit
Always call deinit, even after a successful finish().
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 deinit(af: *AtomicFile) void {
if (af.file_open) {
af.file_writer.file.close();
af.file_open = false;
}
if (af.file_exists) {
const tmp_sub_path = std.fmt.hex(af.random_integer);
af.dir.deleteFile(&tmp_sub_path) catch {};
af.file_exists = false;
}
if (af.close_dir_on_deinit) {
af.dir.close();
}
af.* = undefined;
}