diff 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
line wrap: on
line diff
--- a/src/os/win32/ngx_files.c
+++ b/src/os/win32/ngx_files.c
@@ -430,6 +430,8 @@ ngx_open_dir(ngx_str_t *name, ngx_dir_t 
 
     dir->dir = FindFirstFile((const char *) name->data, &dir->finddata);
 
+    name->data[name->len] = '\0';
+
     if (dir->dir == INVALID_HANDLE_VALUE) {
         return NGX_ERROR;
     }
@@ -459,6 +461,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)
 {
     u_char     *p;