file-locker

Crates.iofile-locker
lib.rsfile-locker
version1.1.3
sourcesrc
created_at2020-07-25 08:08:37.191557
updated_at2024-09-02 01:21:46.419611
descriptionFile locking via POSIX advisory record locks
homepagehttps://sr.ht/~zethra/file-locker/
repositoryhttps://git.sr.ht/~zethra/file-locker/
max_upload_size
id269432
size19,492
Sashanoraa (gaykitty)

documentation

README

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

Sashanoraa <sasha@noraa.gay>

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.

Commit count: 0

cargo fmt