[PATCH 07 of 12] Win32: reworked ngx_win32_rename_file() to use nginx wrappers

Maxim Dounin mdounin at mdounin.ru
Thu Jan 12 21:35:30 UTC 2023


# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1673548972 -10800
#      Thu Jan 12 21:42:52 2023 +0300
# Node ID c86a1405cba4d5c1be6d1bbf3160ba567b3c6f50
# Parent  bed2302585d8647df3f8185085588395b1ce7b74
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).

diff -r bed2302585d8 -r c86a1405cba4 src/os/win32/ngx_files.c
--- a/src/os/win32/ngx_files.c	Thu Jan 12 21:42:48 2023 +0300
+++ b/src/os/win32/ngx_files.c	Thu Jan 12 21:42:52 2023 +0300
@@ -231,7 +231,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;
         }
 
@@ -247,14 +247,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