Function pread64
pub unsafe fn pread64(
fd: i32,
buf: &mut [u8],
offset: isize,
) -> Result<isize, i32> ⓘ
Available on crate feature
dep_nc
only.Expand description
Read from a file descriptor without changing file offset.
§Examples
let path = "/etc/passwd";
let ret = unsafe { nc::openat(nc::AT_FDCWD, path, nc::O_RDONLY, 0) };
assert!(ret.is_ok());
let fd = ret.unwrap();
let mut buf = [0_u8; 128];
let read_count = 64;
let ret = unsafe { nc::pread64(fd, &mut buf[..read_count], 0) };
assert!(ret.is_ok());
assert_eq!(ret, Ok(read_count as nc::ssize_t));
let ret = unsafe { nc::close(fd) };
assert!(ret.is_ok());