Skip to main content

atomic_create_file

Function atomic_create_file 

Source
pub fn atomic_create_file(path: &Path) -> Result<File>
Expand description

Atomically creates a new file at path, failing if it already exists.

Uses O_CREAT | O_EXCL semantics via create_new(true) so that file creation is race-free. On Unix systems the file is created with mode 0o644.

ยงErrors

Returns io::ErrorKind::AlreadyExists if the path already exists, or any other I/O error from the underlying open call.