#linux

file-locker

File locking via POSIX advisory record locks

4 stable releases

1.0.5 Nov 8, 2020
1.0.4 Aug 4, 2020
1.0.2 Jul 25, 2020

#103 in #linux

Download history 13/week @ 2021-06-03 20/week @ 2021-06-10 7/week @ 2021-06-17 7/week @ 2021-06-24 13/week @ 2021-07-01 8/week @ 2021-07-08 254/week @ 2021-07-15 194/week @ 2021-07-22 51/week @ 2021-07-29 50/week @ 2021-08-05 77/week @ 2021-08-12 63/week @ 2021-08-19 126/week @ 2021-08-26 30/week @ 2021-09-02 40/week @ 2021-09-09 33/week @ 2021-09-16

81 downloads per month
Used in 3 crates (via linicon)

MIT license

18KB
273 lines

file-locker

File locking via POSIX advisory record locks (fork of file-lock)

This crate provides the facility to lock and unlock a file following the advisory record lock scheme as specified by UNIX IEEE Std 1003.1-2001 (POSIX.1) via fcntl().

This crate currently supports Linux and FreeBSD.

USAGE

use file_lock::FileLock;
use std::io::prelude::*;
use std::io::Result;

fn main() -> Result<()> {
    let filelock = FileLock::new("myfile.txt")
                    .writeable(true)
                    .blocking(true)
                    .lock()?;

    filelock.file.write_all(b"Hello, World!")?;

    // Manually unlocking is optional as we unlock on Drop
    filelock.unlock();
}

DOCUMENTATION

SUPPORT

Please report any bugs at:

Or by email at:

AUTHORS

Ben Goldberg <benaagoldberg@gmail.com>

Alfie John <alfie@alfie.wtf>

Sebastian Thiel <byronimo@gmail.com>

Contribution

Contribution welcome!

Please send any patches to ~zethra/public-inbox@lists.sr.ht

If you need help sending a patch over email please see this guide

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, shall be licensed under the MIT license, without any additional terms or conditions.

Dependencies

~1MB
~23K SLoC