Skip to main content

sync_dir

Function sync_dir 

Source
pub fn sync_dir(path: &Path) -> Result<()>
Expand description

Durably sync a directory so recently created, renamed, or removed entries survive a crash.

Syncing a file is not enough: the directory entry pointing at it must be synced too. Pair with synced file writes in leaf-up order: sync each file, rename it into place, then sync the parent directory. Errors propagate to the caller; a failed sync must never be silently ignored, or durability is lost without notice.

§Platform notes

Unix opens directories with a plain read-only handle. Windows requires FILE_FLAG_BACKUP_SEMANTICS to open a directory at all, set here via OpenOptionsExt::custom_flags from std::os::windows::fs.

§Errors

Returns an error when the directory cannot be opened or synced.