//go:build windows package evidence import ( "fmt" "syscall" ) // syncDirectory uses an explicit directory handle because os.Open(...).Sync is not a portable // Windows directory durability boundary. Any unsupported filesystem or access failure is fatal: // callers must not make the corresponding evidence row visible in SQLite. func syncDirectory(path string) error { pathPointer, err := syscall.UTF16PtrFromString(path) if err != nil { return fmt.Errorf("encode directory path for durability sync: %w", err) } handle, err := syscall.CreateFile( pathPointer, syscall.GENERIC_WRITE, syscall.FILE_SHARE_READ|syscall.FILE_SHARE_WRITE|syscall.FILE_SHARE_DELETE, nil, syscall.OPEN_EXISTING, syscall.FILE_FLAG_BACKUP_SEMANTICS, 0, ) if err != nil { return fmt.Errorf("open directory for durability sync: %w", err) } defer syscall.CloseHandle(handle) if err := syscall.FlushFileBuffers(handle); err != nil { return fmt.Errorf("flush directory metadata: %w", err) } return nil }