syslib 0.0.0

Use the Linux ABI on Rust, without C.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::os::unix::prelude::OsStrExt;

use syslib::*;

fn main() {
    let mut buffer = [0; 4096];
    write(Fd::stdout, "File: ".as_bytes()).unwrap();
    let path = read(Fd::stdin, &mut buffer).unwrap();
    let path = std::path::Path::new(std::ffi::OsStr::from_bytes(path.strip_suffix(b"\n").unwrap()));
    let fd = open(path, open::Flags::CREATE | open::Flags::WRITE_ONLY, mode!(rw_ ___ ___)).unwrap();
    loop {
        let data = read(Fd::stdin, &mut buffer).unwrap();
        if data == b"\x1b\n" { break }
        if write(&fd, data).unwrap() == 0 {
            break
        }
    }
}