1//go:build !windows
2
3package moxio
4
5import (
6 "fmt"
7 "os"
8
9 "github.com/mjl-/mox/mlog"
10)
11
12// SyncDir opens a directory and syncs its contents to disk.
13func SyncDir(log mlog.Log, dir string) error {
14 d, err := os.Open(dir)
15 if err != nil {
16 return fmt.Errorf("open directory: %v", err)
17 }
18 err = d.Sync()
19 xerr := d.Close()
20 log.Check(xerr, "closing directory after sync")
21 return err
22}
23