0
0
mirror of https://github.com/python/cpython.git synced 2024-11-28 08:20:55 +01:00
cpython/PC/generrmap.c
Antoine Pitrou a762285831 Issue #12802: the Windows error ERROR_DIRECTORY (numbered 267) is now
mapped to POSIX errno ENOTDIR (previously EINVAL).
2011-09-01 21:37:43 +02:00

30 lines
746 B
C

#include <windows.h>
#include <fcntl.h>
#include <io.h>
#include <stdio.h>
#include <errno.h>
/* Extract the mapping of Win32 error codes to errno */
int main()
{
int i;
_setmode(fileno(stdout), O_BINARY);
printf("/* Generated file. Do not edit. */\n");
printf("int winerror_to_errno(int winerror)\n");
printf("{\n switch(winerror) {\n");
for(i=1; i < 65000; i++) {
_dosmaperr(i);
if (errno == EINVAL) {
/* Issue #12802 */
if (i == ERROR_DIRECTORY)
errno = ENOTDIR;
else
continue;
}
printf(" case %d: return %d;\n", i, errno);
}
printf(" default: return EINVAL;\n");
printf(" }\n}\n");
}