|new 3.0.9||Jan 23, 2023|
|3.0.8||Nov 9, 2022|
|3.0.6||Jun 21, 2022|
|3.0.5||Mar 23, 2022|
|1.1.0||Jun 28, 2019|
#12 in Operating systems
229,602 downloads per month
Used in 256 crates (17 directly)
Advisory cross-platform file locks using file descriptors. Adapted from mafintosh/fd-lock.
Note that advisory lock compliance is opt-in, and can freely be ignored by other parties. This means this crate should never be used for security purposes, but solely to coordinate file access.
use std::io::prelude::*; use std::fs::File; use fd_lock::RwLock; // Lock a file and write to it. let mut f = RwLock::new(File::open("foo.txt")?); write!(f.write()?, "chashu cat")?; // A lock can also be held across multiple operations. let mut f = f.write()?; write!(f, "nori cat")?; write!(f, "bird!")?;
$ cargo add fd-lock
This crate uses
unsafe on Windows to interface with
invariants have been carefully checked, and are manually enforced.
Want to join us? Check out our "Contributing" guide and take a look at some of these issues:
- LockFile function - WDC
- flock(2) - Linux Man Page