use std::fs::File;
use std::path::Path;
use crate::Result;
#[cfg(target_vendor = "apple")]
pub(super) fn full_sync(file: &File) -> std::io::Result<()> {
rustix::fs::fcntl_fullfsync(file).map_err(std::io::Error::from)
}
#[cfg(not(target_vendor = "apple"))]
pub(super) fn full_sync(file: &File) -> std::io::Result<()> {
file.sync_data()
}
#[cfg(unix)]
pub(super) fn sync_directory(dir: &Path) -> Result<()> {
File::open(dir)
.and_then(|handle| handle.sync_all())
.map_err(|error| crate::Error::io("sync directory", dir, error))
}
#[cfg(not(unix))]
pub(super) fn sync_directory(_dir: &Path) -> Result<()> {
Ok(())
}