use std::os::fd::RawFd;
use std::path::Path;
use crate::CPathBuf;
#[cfg(target_os = "macos")]
const _PC_MIN_HOLE_SIZE: i32 = 27;
pub fn fd_min_hole_size(fd: RawFd) -> std::io::Result<i64> {
let long = unsafe { libc::fpathconf(fd, _PC_MIN_HOLE_SIZE) };
if long == -1 {
return Err(std::io::Error::last_os_error());
}
Ok(long)
}
pub fn path_min_hole_size(path: &Path) -> std::io::Result<u64> {
let path: CPathBuf = path.try_into()?;
let long = unsafe { libc::pathconf(path.as_ptr(), _PC_MIN_HOLE_SIZE) };
if long == -1 {
return Err(std::io::Error::last_os_error());
}
Ok(long as u64)
}