Mercurial > hg > nginx
changeset 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 | 5f6144fc674d |
files | src/os/win32/ngx_files.c |
diffstat | 1 files changed, 17 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/os/win32/ngx_files.c Wed Sep 16 13:28:20 2009 +0000 +++ b/src/os/win32/ngx_files.c Wed Sep 16 13:30:13 2009 +0000 @@ -319,12 +319,24 @@ 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 @@ sb->nFileSizeHigh = fa.nFileSizeHigh; sb->nFileSizeLow = fa.nFileSizeLow; - return ~NGX_FILE_ERROR; + return rc; }