github.com/tetratelabs/wazero@v1.2.1/internal/sysfs/sync_windows.go (about)

     1  package sysfs
     2  
     3  import (
     4  	"os"
     5  	"syscall"
     6  
     7  	"github.com/tetratelabs/wazero/internal/platform"
     8  )
     9  
    10  func fsync(f *os.File) syscall.Errno {
    11  	errno := platform.UnwrapOSError(f.Sync())
    12  	// Coerce error performing stat on a directory to 0, as it won't work
    13  	// on Windows.
    14  	switch errno {
    15  	case syscall.EACCES /* Go 1.20 */, syscall.EBADF /* Go 1.18 */ :
    16  		if st, err := f.Stat(); err == nil && st.IsDir() {
    17  			errno = 0
    18  		}
    19  	}
    20  	return errno
    21  }