github.com/tetratelabs/wazero@v1.7.3-0.20240513003603-48f702e154b5/internal/sysfs/sync_windows.go (about)

     1  package sysfs
     2  
     3  import (
     4  	"os"
     5  
     6  	"github.com/tetratelabs/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  }