use std::path::Path;
use crate::error::Error;
pub fn unlink<P: AsRef<Path>>(file: P) -> Result<(), Error> {
unsafe { nc::unlinkat(nc::AT_FDCWD, file.as_ref(), 0).map_err(Into::into) }
}
#[cfg(test)]
mod tests {
use super::unlink;
#[test]
fn test_unlink() {
let path = "/tmp/shell-rs-unlink";
let ret = unsafe { nc::open(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());
assert!(unlink(path).is_ok());
}
}