diff src/os/win32/ngx_files.c @ 3138:a2479937dbd8

win32 ngx_file_info() utf8 support
author Igor Sysoev <igor@sysoev.ru>
date Wed, 16 Sep 2009 13:30:13 +0000
parents 179f6dfcb7fe
children 55f006d944ba
line wrap: on
line diff
--- a/src/os/win32/ngx_files.c
+++ b/src/os/win32/ngx_files.c
@@ -319,12 +319,24 @@ ngx_win32_rename_file(ngx_str_t *from, n
 ngx_int_t
 ngx_file_info(u_char *file, ngx_file_info_t *sb)
 {
-    WIN32_FILE_ATTRIBUTE_DATA  fa;
+    long                        rc;
+    u_short                    *u;
+    ngx_err_t                   err;
+    WIN32_FILE_ATTRIBUTE_DATA   fa;
+    u_short                     utf16[NGX_UTF16_BUFLEN];
+
+    u = ngx_utf8_to_utf16(utf16, file, NGX_UTF16_BUFLEN);
 
-    /* NT4 and Win98 */
+    if (u == NULL) {
+        return NGX_FILE_ERROR;
+    }
 
-    if (GetFileAttributesEx((char *) file, GetFileExInfoStandard, &fa) == 0) {
-        return NGX_FILE_ERROR;
+    rc = GetFileAttributesExW(u, GetFileExInfoStandard, &fa);
+
+    if (u != utf16) {
+        err = ngx_errno;
+        ngx_free(u);
+        ngx_set_errno(err);
     }
 
     sb->dwFileAttributes = fa.dwFileAttributes;
@@ -334,7 +346,7 @@ ngx_file_info(u_char *file, ngx_file_inf
     sb->nFileSizeHigh = fa.nFileSizeHigh;
     sb->nFileSizeLow = fa.nFileSizeLow;
 
-    return ~NGX_FILE_ERROR;
+    return rc;
 }