forked from facebook/watchman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrmap.cpp
78 lines (73 loc) · 1.8 KB
/
errmap.cpp
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/* Copyright 2012-present Facebook, Inc.
* Licensed under the Apache License, Version 2.0 */
#include "watchman.h"
const char* win32_strerror(DWORD err) {
static __declspec(thread) char msgbuf[1024];
FormatMessageA(
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
err,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
msgbuf,
sizeof(msgbuf) - 1,
NULL);
return msgbuf;
}
int map_win32_err(DWORD err) {
switch (err) {
case ERROR_SUCCESS:
return 0;
case ERROR_ALREADY_EXISTS:
return EEXIST;
case ERROR_TIMEOUT:
return ETIMEDOUT;
case WAIT_TIMEOUT:
return ETIMEDOUT;
case WAIT_IO_COMPLETION:
return EINTR;
case ERROR_INVALID_FUNCTION:
return ENOSYS;
case ERROR_PATH_NOT_FOUND:
return ENOTDIR;
case ERROR_FILE_NOT_FOUND:
return ENOENT;
case ERROR_TOO_MANY_OPEN_FILES:
return EMFILE;
case ERROR_ACCESS_DENIED:
return EACCES;
case ERROR_INVALID_HANDLE:
return EBADF;
case ERROR_NOT_ENOUGH_MEMORY:
return ENOMEM;
case ERROR_INVALID_ACCESS:
return EACCES;
case ERROR_INVALID_DATA:
return EINVAL;
case ERROR_NO_MORE_FILES:
return EMFILE;
case ERROR_WRITE_PROTECT:
return EPERM;
case ERROR_NOT_SUPPORTED:
return ENOSYS;
case ERROR_DEV_NOT_EXIST:
return ENOENT;
case ERROR_FILE_EXISTS:
return EEXIST;
case ERROR_INVALID_PARAMETER:
return EINVAL;
case ERROR_NO_PROC_SLOTS:
return EAGAIN;
case ERROR_BROKEN_PIPE:
return EPIPE;
case ERROR_DISK_FULL:
return ENOSPC;
case ERROR_IO_INCOMPLETE:
return EAGAIN;
case ERROR_IO_PENDING:
return EAGAIN;
case WSAECONNREFUSED:
return ECONNREFUSED;
default:
return EINVAL;
}
}