binstalk-manifests 0.19.4

The binstall toolkit for manipulating with manifest
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use std::{fs, io, path::Path};

use fs_lock::FileLock;

/// Return exclusively locked file that is readable and writable.
pub(crate) fn create_if_not_exist(path: &Path) -> io::Result<FileLock> {
    fs::File::options()
        .read(true)
        .write(true)
        .create(true)
        .truncate(false)
        .open(path)
        .and_then(FileLock::new_exclusive)
        .map(|file_lock| file_lock.set_file_path(path))
}