-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy patherror_windows.go
More file actions
46 lines (43 loc) · 1.22 KB
/
error_windows.go
File metadata and controls
46 lines (43 loc) · 1.22 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package mdbx
/*
#include <errno.h>
#include "mdbxgo.h"
*/
import "C"
import "syscall"
func operrno(op string, ret C.int) error {
if ret == C.MDBX_SUCCESS || ret == C.MDBX_RESULT_TRUE {
return nil
}
if ret == C.MDBX_NOTFOUND {
return ErrNotFound
}
if minErrno <= ret && ret <= maxErrno {
return &OpError{Op: op, Errno: Errno(ret)}
}
// translate C errors into corresponding syscall.Errno values so that
// IsErrnoSys functions correctly, a kludge unknowning inherited from LMDB.
// the errno in the returned OpError cannot be passed to C.mdbx_strerror.
// see the implementation of C.mdbx_strerror for information about how the
// following table was generated.
var errno syscall.Errno
switch ret {
case C.ENOENT:
errno = syscall.ENOENT /* 2, FILE_NOT_FOUND */
case C.EIO:
errno = syscall.EIO /* 5, ACCESS_DENIED */
case C.ENOMEM:
errno = syscall.ENOMEM /* 12, INVALID_ACCESS */
case C.EACCES:
errno = syscall.EACCES /* 13, INVALID_DATA */
case C.EBUSY:
errno = syscall.EBUSY /* 16, CURRENT_DIRECTORY */
case C.EINVAL:
errno = syscall.EINVAL /* 22, BAD_COMMAND */
case C.ENOSPC:
errno = syscall.ENOSPC /* 28, OUT_OF_PAPER */
default:
errno = syscall.Errno(ret)
}
return &OpError{Op: op, Errno: errno}
}