github.com/wasilibs/wazerox@v0.0.0-20240124024944-4923be63ab5f/internal/sysfs/unlink_windows.go (about) 1 package sysfs 2 3 import ( 4 "os" 5 "syscall" 6 7 "github.com/wasilibs/wazerox/experimental/sys" 8 ) 9 10 func unlink(name string) sys.Errno { 11 err := syscall.Unlink(name) 12 if err == nil { 13 return 0 14 } 15 errno := sys.UnwrapOSError(err) 16 if errno == sys.EBADF { 17 lstat, errLstat := os.Lstat(name) 18 if errLstat == nil && lstat.Mode()&os.ModeSymlink != 0 { 19 errno = sys.UnwrapOSError(os.Remove(name)) 20 } else { 21 errno = sys.EISDIR 22 } 23 } 24 return errno 25 }