File: errors_windows.go

package info (click to toggle)
golang-github-hugelgupf-p9 0.3.0-2.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 608 kB
  • sloc: makefile: 9
file content (28 lines) | stat: -rw-r--r-- 498 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//go:build windows
// +build windows

package linux

import (
	"errors"
	"syscall"
)

func sysErrno(err error) Errno {
	for _, pair := range []struct {
		error
		Errno
	}{
		{syscall.ERROR_FILE_NOT_FOUND, ENOENT},
		{syscall.ERROR_PATH_NOT_FOUND, ENOENT},
		{syscall.ERROR_ACCESS_DENIED, EACCES},
		{syscall.ERROR_FILE_EXISTS, EEXIST},
		{syscall.ERROR_INSUFFICIENT_BUFFER, ENOMEM},
	} {
		if errors.Is(err, pair.error) {
			return pair.Errno
		}
	}
	// No clue what to do with others.
	return 0
}