Function nc::open

source ·
pub unsafe fn open<P: AsRef<Path>>(
    filename: P,
    flags: i32,
    mode: mode_t
) -> Result<i32, Errno>
Expand description

Open and possibly create a file.

§Example

let path = "/etc/passwd";
let ret = unsafe { nc::open(path, nc::O_RDONLY, 0) };
assert!(ret.is_ok());
let fd = ret.unwrap();
let ret = unsafe { nc::close(fd) };
assert!(ret.is_ok());