[nginx] Win32: reworked ngx_win32_rename_file() to use nginx wrappers.

Sergey Kandaurov pluknet at nginx.com
Fri Feb 24 10:33:05 UTC 2023


details:   https://hg.nginx.org/nginx/rev/37a184966ab3
branches:  
changeset: 8136:37a184966ab3
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Thu Feb 23 20:49:52 2023 +0300
description:
Win32: reworked ngx_win32_rename_file() to use nginx wrappers.

This ensures that ngx_win32_rename_file() will support non-ASCII names
when supported by the wrappers.

Notably, this is used by PUT requests in the dav module when overwriting
existing files with non-ASCII names (ticket #1433).

diffstat:

 src/os/win32/ngx_files.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (29 lines):

diff -r 8880fe0b193c -r 37a184966ab3 src/os/win32/ngx_files.c
--- a/src/os/win32/ngx_files.c	Thu Feb 23 20:49:50 2023 +0300
+++ b/src/os/win32/ngx_files.c	Thu Feb 23 20:49:52 2023 +0300
@@ -232,7 +232,7 @@ ngx_win32_rename_file(ngx_str_t *from, n
 
         ngx_sprintf(name + to->len, ".%0muA.DELETE%Z", num);
 
-        if (MoveFile((const char *) to->data, (const char *) name) != 0) {
+        if (ngx_rename_file(to->data, name) != NGX_FILE_ERROR) {
             break;
         }
 
@@ -248,14 +248,14 @@ ngx_win32_rename_file(ngx_str_t *from, n
         goto failed;
     }
 
-    if (MoveFile((const char *) from->data, (const char *) to->data) == 0) {
+    if (ngx_rename_file(from->data, to->data) == NGX_FILE_ERROR) {
         err = ngx_errno;
 
     } else {
         err = 0;
     }
 
-    if (DeleteFile((const char *) name) == 0) {
+    if (ngx_delete_file(name) == NGX_FILE_ERROR) {
         ngx_log_error(NGX_LOG_CRIT, log, ngx_errno,
                       "DeleteFile() \"%s\" failed", name);
     }


More information about the nginx-devel mailing list