use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Arc, Mutex, RwLock};
-#[cfg(not(target_os = "windows"))]
-use std::os::unix::io::AsRawFd;
-
#[cfg(target_os = "windows")]
use {std::ffi::OsStr, std::os::windows::ffi::OsStrExt};
{
fs::rename(&tmp_file_path, &dest_file_path)?;
let dir_file = fs::OpenOptions::new().read(true).open(&parent_directory)?;
- unsafe {
- libc::fsync(dir_file.as_raw_fd());
- }
+ dir_file.sync_all()?;
Ok(())
}
std::io::Error::new(std::io::ErrorKind::InvalidInput, msg)
})?;
let dir_file = fs::OpenOptions::new().read(true).open(parent_directory)?;
- unsafe {
- // The above call to `fs::remove_file` corresponds to POSIX `unlink`, whose changes
- // to the inode might get cached (and hence possibly lost on crash), depending on
- // the target platform and file system.
- //
- // In order to assert we permanently removed the file in question we therefore
- // call `fsync` on the parent directory on platforms that support it,
- libc::fsync(dir_file.as_raw_fd());
- }
+ // The above call to `fs::remove_file` corresponds to POSIX `unlink`, whose changes
+ // to the inode might get cached (and hence possibly lost on crash), depending on
+ // the target platform and file system.
+ //
+ // In order to assert we permanently removed the file in question we therefore
+ // call `fsync` on the parent directory on platforms that support it,
+ dir_file.sync_all()?;
}
if dest_file_path.is_file() {