comparison 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
comparison
equal deleted inserted replaced
3137:179f6dfcb7fe 3138:a2479937dbd8
317 317
318 318
319 ngx_int_t 319 ngx_int_t
320 ngx_file_info(u_char *file, ngx_file_info_t *sb) 320 ngx_file_info(u_char *file, ngx_file_info_t *sb)
321 { 321 {
322 WIN32_FILE_ATTRIBUTE_DATA fa; 322 long rc;
323 323 u_short *u;
324 /* NT4 and Win98 */ 324 ngx_err_t err;
325 325 WIN32_FILE_ATTRIBUTE_DATA fa;
326 if (GetFileAttributesEx((char *) file, GetFileExInfoStandard, &fa) == 0) { 326 u_short utf16[NGX_UTF16_BUFLEN];
327
328 u = ngx_utf8_to_utf16(utf16, file, NGX_UTF16_BUFLEN);
329
330 if (u == NULL) {
327 return NGX_FILE_ERROR; 331 return NGX_FILE_ERROR;
332 }
333
334 rc = GetFileAttributesExW(u, GetFileExInfoStandard, &fa);
335
336 if (u != utf16) {
337 err = ngx_errno;
338 ngx_free(u);
339 ngx_set_errno(err);
328 } 340 }
329 341
330 sb->dwFileAttributes = fa.dwFileAttributes; 342 sb->dwFileAttributes = fa.dwFileAttributes;
331 sb->ftCreationTime = fa.ftCreationTime; 343 sb->ftCreationTime = fa.ftCreationTime;
332 sb->ftLastAccessTime = fa.ftLastAccessTime; 344 sb->ftLastAccessTime = fa.ftLastAccessTime;
333 sb->ftLastWriteTime = fa.ftLastWriteTime; 345 sb->ftLastWriteTime = fa.ftLastWriteTime;
334 sb->nFileSizeHigh = fa.nFileSizeHigh; 346 sb->nFileSizeHigh = fa.nFileSizeHigh;
335 sb->nFileSizeLow = fa.nFileSizeLow; 347 sb->nFileSizeLow = fa.nFileSizeLow;
336 348
337 return ~NGX_FILE_ERROR; 349 return rc;
338 } 350 }
339 351
340 352
341 ngx_int_t 353 ngx_int_t
342 ngx_set_file_time(u_char *name, ngx_fd_t fd, time_t s) 354 ngx_set_file_time(u_char *name, ngx_fd_t fd, time_t s)