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.
This commit is contained in:
Maxim Dounin 2014-07-05 23:29:47 +04:00
parent 31c1715ce6
commit 11bbbc051b
2 changed files with 14 additions and 1 deletions

View File

@ -430,6 +430,8 @@ ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir)
dir->dir = FindFirstFile((const char *) name->data, &dir->finddata);
name->data[name->len] = '\0';
if (dir->dir == INVALID_HANDLE_VALUE) {
return NGX_ERROR;
}
@ -458,6 +460,17 @@ ngx_read_dir(ngx_dir_t *dir)
}
ngx_int_t
ngx_close_dir(ngx_dir_t *dir)
{
if (FindClose(dir->dir) == 0) {
return NGX_ERROR;
}
return NGX_OK;
}
ngx_int_t
ngx_open_glob(ngx_glob_t *gl)
{

View File

@ -193,7 +193,7 @@ ngx_int_t ngx_read_dir(ngx_dir_t *dir);
#define ngx_read_dir_n "FindNextFile()"
#define ngx_close_dir(d) FindClose((d)->dir)
ngx_int_t ngx_close_dir(ngx_dir_t *dir);
#define ngx_close_dir_n "FindClose()"