devela::_dep::nc::call

Function pwrite64

pub unsafe fn pwrite64(fd: i32, buf: &[u8], offset: i64) -> Result<isize, i32> 
Available on crate feature dep_nc only.
Expand description

Write to a file descriptor without changing file offset.

§Examples

let path = "/tmp/nc-pwrite64";
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 msg = "Hello, Rust";
let ret = unsafe { nc::pwrite64(fd, msg.as_bytes(), 0) };
assert!(ret.is_ok());
assert_eq!(ret, Ok(msg.len() as nc::ssize_t));
let ret = unsafe { nc::close(fd) };
assert!(ret.is_ok());
let ret = unsafe { nc::unlinkat(nc::AT_FDCWD, path, 0) };
assert!(ret.is_ok());