Function truncate
pub unsafe fn truncate<P>(filename: P, length: isize) -> Result<(), i32> ⓘ
Available on crate feature
dep_nc
only.Expand description
Truncate a file to a specified length.
§Examples
let path = "/tmp/nc-truncate";
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());
let ret = unsafe { nc::truncate(path, 64 * 1024) };
assert!(ret.is_ok());
let ret = unsafe { nc::unlinkat(nc::AT_FDCWD, path, 0) };
assert!(ret.is_ok());