File: locks_until_nl.rs

package info (click to toggle)
rust-fslock 0.2.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 224 kB
  • sloc: makefile: 9
file content (26 lines) | stat: -rw-r--r-- 584 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#[cfg(feature = "std")]
use fslock::LockFile;
#[cfg(feature = "std")]
use std::{env, io, io::Read, process};

#[cfg(feature = "std")]
fn main() -> Result<(), fslock::Error> {
    let mut args = env::args();
    args.next();

    let path = match args.next() {
        Some(arg) if args.next().is_none() => arg,
        _ => {
            eprintln!("Expected one argument");
            process::exit(1);
        },
    };
    let mut lockfile = LockFile::open(&path)?;
    lockfile.lock()?;
    io::stdin().read(&mut [0; 1])?;

    Ok(())
}

#[cfg(not(feature = "std"))]
fn main() {}