libfreemkv 1.1.0

Open source raw disc access library for optical drives
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! POSIX directory-fsync. Active on unix and any non-Windows fallback target
//! (BSD, illumos, …) — all share the same `File::open(dir).sync_all()`
//! semantics. The Windows no-op lives in the sibling `windows` module.

use std::path::Path;

pub(super) fn fsync_dir(dir: &Path) {
    match std::fs::File::open(dir) {
        Ok(f) => {
            if let Err(e) = f.sync_all() {
                tracing::warn!(path = %dir.display(), error = %e, "failed to fsync directory");
            }
        }
        Err(e) => {
            tracing::warn!(path = %dir.display(), error = %e, "could not open directory to fsync");
        }
    }
}