# HG changeset patch # User Maxim Dounin # Date 1459234306 -10800 # Node ID a5897d360977e37ea817736727657580b2a43a11 # Parent 91c8d990fb4540f9937e97426586b29be6185e21 Win32: additional error code NGX_EEXIST_FILE (ticket #910). On Windows there are two possible error codes which correspond to the EEXIST error code: ERROR_FILE_EXISTS used by CreateFile(CREATE_NEW), and ERROR_ALREADY_EXISTS used by CreateDirectory(). MoveFile() seems to use both: ERROR_ALREADY_EXISTS when moving within one filesystem, and ERROR_FILE_EXISTS when copying a file to a different drive. diff -r 91c8d990fb45 -r a5897d360977 src/core/ngx_file.c --- a/src/core/ngx_file.c Mon Mar 28 19:50:19 2016 +0300 +++ b/src/core/ngx_file.c Tue Mar 29 09:51:46 2016 +0300 @@ -196,7 +196,7 @@ err = ngx_errno; - if (err == NGX_EEXIST) { + if (err == NGX_EEXIST_FILE) { n = (uint32_t) ngx_next_temp_number(1); continue; } @@ -692,7 +692,7 @@ #if (NGX_WIN32) - if (err == NGX_EEXIST) { + if (err == NGX_EEXIST || err == NGX_EEXIST_FILE) { err = ngx_win32_rename_file(src, to, ext->log); if (err == 0) { diff -r 91c8d990fb45 -r a5897d360977 src/os/unix/ngx_errno.h --- a/src/os/unix/ngx_errno.h Mon Mar 28 19:50:19 2016 +0300 +++ b/src/os/unix/ngx_errno.h Tue Mar 29 09:51:46 2016 +0300 @@ -25,6 +25,7 @@ #define NGX_EACCES EACCES #define NGX_EBUSY EBUSY #define NGX_EEXIST EEXIST +#define NGX_EEXIST_FILE EEXIST #define NGX_EXDEV EXDEV #define NGX_ENOTDIR ENOTDIR #define NGX_EISDIR EISDIR diff -r 91c8d990fb45 -r a5897d360977 src/os/win32/ngx_errno.h --- a/src/os/win32/ngx_errno.h Mon Mar 28 19:50:19 2016 +0300 +++ b/src/os/win32/ngx_errno.h Tue Mar 29 09:51:46 2016 +0300 @@ -25,8 +25,14 @@ #define NGX_ENOPATH ERROR_PATH_NOT_FOUND #define NGX_ENOMEM ERROR_NOT_ENOUGH_MEMORY #define NGX_EACCES ERROR_ACCESS_DENIED -/* it's seems that ERROR_FILE_EXISTS is not appropriate error code */ +/* + * there are two EEXIST error codes: + * ERROR_FILE_EXISTS used by CreateFile(CREATE_NEW), + * and ERROR_ALREADY_EXISTS used by CreateDirectory(); + * MoveFile() uses both + */ #define NGX_EEXIST ERROR_ALREADY_EXISTS +#define NGX_EEXIST_FILE ERROR_FILE_EXISTS /* * could not found cross volume directory move error code, * so use ERROR_WRONG_DISK as stub one