]> git.kaiwu.me - nginx.git/commitdiff
Win32: ngx_open_dir() and ngx_close_dir() fixes.
authorMaxim Dounin <mdounin@mdounin.ru>
Sat, 5 Jul 2014 19:29:47 +0000 (23:29 +0400)
committerMaxim Dounin <mdounin@mdounin.ru>
Sat, 5 Jul 2014 19:29:47 +0000 (23:29 +0400)
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.

src/os/win32/ngx_files.c
src/os/win32/ngx_files.h

index 32e28b5d472d00e65386c359ac2d16a5dfa087ea..881ffefb482af0a35a5932f3cfcf9011028e32af 100644 (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)
 {
index 08e5dc67e3f22853f2efea143e6db1437b95fa7b..aafb5d0b41011653be046578bfa207593870e758 100644 (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()"