github.com/wasilibs/wazerox@v0.0.0-20240124024944-4923be63ab5f/internal/sysfs/sync_windows.go (about) 1 package sysfs 2 3 import ( 4 "os" 5 6 "github.com/wasilibs/wazerox/experimental/sys" 7 ) 8 9 func fsync(f *os.File) sys.Errno { 10 errno := sys.UnwrapOSError(f.Sync()) 11 // Coerce error performing stat on a directory to 0, as it won't work 12 // on Windows. 13 switch errno { 14 case sys.EACCES /* Go 1.20 */, sys.EBADF /* Go 1.19 */ : 15 if st, err := f.Stat(); err == nil && st.IsDir() { 16 errno = 0 17 } 18 } 19 return errno 20 }