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