Function nc::renameat2 [−][src]
pub fn renameat2<P: AsRef<Path>>(
olddfd: i32,
oldfilename: P,
newdfd: i32,
newfilename: P,
flags: i32
) -> Result<(), Errno>
Expand description
Change name or location of a file.
let path = "/tmp/nc-renameat2";
let ret = nc::open(path, nc::O_WRONLY | nc::O_CREAT, 0o644);
assert!(ret.is_ok());
let fd = ret.unwrap();
assert!(nc::close(fd).is_ok());
let new_path = "/tmp/nc-renameat2-new";
let flags = nc::RENAME_NOREPLACE;
let ret = nc::renameat2(nc::AT_FDCWD, path, nc::AT_FDCWD, new_path, flags);
assert!(ret.is_ok());
assert!(nc::unlink(new_path).is_ok());