github.com/bananabytelabs/wazero@v0.0.0-20240105073314-54b22a776da8/internal/sysfs/sync_windows.go (about) 1 package sysfs 2 3 import ( 4 "os" 5 6 "github.com/bananabytelabs/wazero/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 }