Crates.io | fslock-arti-fork |
lib.rs | fslock-arti-fork |
version | 0.2.0 |
source | src |
created_at | 2024-01-22 16:00:09.367244 |
updated_at | 2024-01-22 16:00:09.367244 |
description | A library to use files as locks, forked for use in Arti. |
homepage | |
repository | https://github.com/nmathewson/fslock/ |
max_upload_size | |
id | 1108930 |
size | 64,595 |
NOTE: This is a fork of the
fslock
crate for use by Arti. We are forking temporarily because we need https://github.com/brunoczim/fslock/pull/15 in order to implement file deletion safely.
API to use files as a lock. Supports non-std crates by disabling feature
std
.
Currently, only one type is provided: [LockFile
]. It does not destroy the
file after closed and behaviour on locking different file handles owned by
the same process is different between Unix and Windows, unless you activate the
multilock
feature, which enables the open_excl
method that locks files per
file descriptor/handle on all platforms.
use fslock::LockFile;
fn main() -> Result<(), fslock::Error> {
let mut file = LockFile::open("mylock")?;
file.lock()?;
do_stuff();
file.unlock()?;
Ok(())
}
https://brunoczim.github.io/fslock/fslock
[]