devela::_dep::nc

Function creat

pub unsafe fn creat<P>(filename: P, mode: u32) -> Result<i32, i32> 
where P: AsRef<Path>,
Available on crate feature dep_nc only.
Expand description

Create a file.

equals to call open() with flags O_CREAT|O_WRONLY|O_TRUNC.

§Examples

let path = "/tmp/nc-creat-file";
let fd = unsafe { nc::creat(path, 0o644) };
assert!(fd.is_ok());
let fd = fd.unwrap();
let ret = unsafe { nc::close(fd) };
assert!(ret.is_ok());
let ret = unsafe { nc::unlinkat(nc::AT_FDCWD, path, 0) };
assert!(ret.is_ok());