use std::fs::File;
use std::io;
#[cfg(target_os = "linux")]
use std::os::fd::AsRawFd;
pub(crate) fn set_len(file: &File, len: i64) -> Result<(), io::Error> {
#[cfg(target_os = "linux")]
match unsafe { libc::posix_fallocate(file.as_raw_fd(), 0, len) } {
0 => Ok(()),
err => Err(io::Error::from_raw_os_error(err)),
}
#[cfg(not(target_os = "linux"))]
file.set_len(len as u64)
}