Crates.io | atomicwrites |
lib.rs | atomicwrites |
version | 0.4.4 |
source | src |
created_at | 2015-01-21 18:14:46.165877 |
updated_at | 2024-09-19 15:30:07.315818 |
description | Atomic file-writes. |
homepage | https://github.com/untitaker/rust-atomicwrites |
repository | https://github.com/untitaker/rust-atomicwrites |
max_upload_size | |
id | 847 |
size | 22,305 |
Atomic file-writes. Works on both POSIX and Windows.
The basic idea is to write to temporary files (in the same file
system), and move them when done writing.
This avoids the problem of two programs writing to the same file. For
AllowOverwrite
, rename
is used. For DisallowOverwrite
, link + unlink
is
used instead to raise errors when the target path already exists.
This is mostly a port of the same-named Python package.
use atomicwrites::{AtomicFile,DisallowOverwrite};
let af = AtomicFile::new("foo", DisallowOverwrite);
af.write(|f| {
f.write_all(b"HELLO")
})?;
persist
method doing the same thing.Licensed under MIT, see LICENSE
.