# HG changeset patch # User Igor Sysoev # Date 1253107813 0 # Node ID a2479937dbd8f7655087fd9fa95370d062ba70f7 # Parent 179f6dfcb7fed595dbcc36d1a11ca266dab00c10 win32 ngx_file_info() utf8 support diff --git a/src/os/win32/ngx_files.c b/src/os/win32/ngx_files.c --- 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; }