devela::_dep::nc::call

Function unlinkat

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

Delete a name and possibly the file it refers to.

§Examples

let path = "/tmp/nc-unlinkat";
let ret = unsafe { nc::openat(nc::AT_FDCWD, path, nc::O_WRONLY | nc::O_CREAT, 0o644) };
assert!(ret.is_ok());
let fd = ret.unwrap();
let ret = unsafe { nc::close(fd) };
assert!(ret.is_ok());
// /tmp folder is not empty, so this call always returns error.
let ret = unsafe { nc::unlinkat(nc::AT_FDCWD, path, nc::AT_REMOVEDIR) };
assert!(ret.is_err());
let ret = unsafe { nc::unlinkat(nc::AT_FDCWD, path, 0) };
assert!(ret.is_ok());