comparison src/os/win32/ngx_files.c @ 5749:a680bf4dddd5

Win32: ngx_open_dir() and ngx_close_dir() fixes. The ngx_open_dir() function changed to restore name passed to it. This fixes removing destination directory in dav module, as caught by dav.t. The ngx_close_dir() function introduced to properly convert errors, as FindClose() returns 0 on error.
author Maxim Dounin <mdounin@mdounin.ru>
date Sat, 05 Jul 2014 23:29:47 +0400
parents 1cd23ca84a9b
children fbdab7f38fd6
comparison
equal deleted inserted replaced
5748:d2c286564fd4 5749:a680bf4dddd5
428 { 428 {
429 ngx_cpystrn(name->data + name->len, NGX_DIR_MASK, NGX_DIR_MASK_LEN + 1); 429 ngx_cpystrn(name->data + name->len, NGX_DIR_MASK, NGX_DIR_MASK_LEN + 1);
430 430
431 dir->dir = FindFirstFile((const char *) name->data, &dir->finddata); 431 dir->dir = FindFirstFile((const char *) name->data, &dir->finddata);
432 432
433 name->data[name->len] = '\0';
434
433 if (dir->dir == INVALID_HANDLE_VALUE) { 435 if (dir->dir == INVALID_HANDLE_VALUE) {
434 return NGX_ERROR; 436 return NGX_ERROR;
435 } 437 }
436 438
437 dir->valid_info = 1; 439 dir->valid_info = 1;
453 dir->type = 1; 455 dir->type = 1;
454 return NGX_OK; 456 return NGX_OK;
455 } 457 }
456 458
457 return NGX_ERROR; 459 return NGX_ERROR;
460 }
461
462
463 ngx_int_t
464 ngx_close_dir(ngx_dir_t *dir)
465 {
466 if (FindClose(dir->dir) == 0) {
467 return NGX_ERROR;
468 }
469
470 return NGX_OK;
458 } 471 }
459 472
460 473
461 ngx_int_t 474 ngx_int_t
462 ngx_open_glob(ngx_glob_t *gl) 475 ngx_open_glob(ngx_glob_t *gl)