Win32: removed NGX_DIR_MASK concept.

Previous interface of ngx_open_dir() assumed that passed directory name
has a room for NGX_DIR_MASK at the end (NGX_DIR_MASK_LEN bytes).  While all
direct users of ngx_dir_open() followed this interface, this also implied
similar requirements for indirect uses - in particular, via ngx_walk_tree().

Currently none of ngx_walk_tree() uses provides appropriate space, and
fixing this does not look like a right way to go.  Instead, ngx_dir_open()
interface was changed to not require any additional space and use
appropriate allocations instead.
diff --git a/src/core/ngx_file.c b/src/core/ngx_file.c
index 5678030..63ada85 100644
--- a/src/core/ngx_file.c
+++ b/src/core/ngx_file.c
@@ -1017,13 +1017,13 @@
 
         file.len = tree->len + 1 + len;
 
-        if (file.len + NGX_DIR_MASK_LEN > buf.len) {
+        if (file.len > buf.len) {
 
             if (buf.len) {
                 ngx_free(buf.data);
             }
 
-            buf.len = tree->len + 1 + len + NGX_DIR_MASK_LEN;
+            buf.len = tree->len + 1 + len;
 
             buf.data = ngx_alloc(buf.len + 1, ctx->log);
             if (buf.data == NULL) {
diff --git a/src/http/modules/ngx_http_autoindex_module.c b/src/http/modules/ngx_http_autoindex_module.c
index d59fba2..30fd601 100644
--- a/src/http/modules/ngx_http_autoindex_module.c
+++ b/src/http/modules/ngx_http_autoindex_module.c
@@ -186,8 +186,6 @@
         return rc;
     }
 
-    /* NGX_DIR_MASK_LEN is lesser than NGX_HTTP_AUTOINDEX_PREALLOCATE */
-
     last = ngx_http_map_uri_to_path(r, &path, &root,
                                     NGX_HTTP_AUTOINDEX_PREALLOCATE);
     if (last == NULL) {
diff --git a/src/http/modules/ngx_http_random_index_module.c b/src/http/modules/ngx_http_random_index_module.c
index b47ee4f..ed00ad5 100644
--- a/src/http/modules/ngx_http_random_index_module.c
+++ b/src/http/modules/ngx_http_random_index_module.c
@@ -98,7 +98,7 @@
     }
 
 #if (NGX_HAVE_D_TYPE)
-    len = NGX_DIR_MASK_LEN;
+    len = 0;
 #else
     len = NGX_HTTP_RANDOM_INDEX_PREALLOCATE;
 #endif
diff --git a/src/os/unix/ngx_files.h b/src/os/unix/ngx_files.h
index 07872b1..383e38e 100644
--- a/src/os/unix/ngx_files.h
+++ b/src/os/unix/ngx_files.h
@@ -213,9 +213,6 @@
 #endif
 
 
-#define NGX_DIR_MASK_LEN         0
-
-
 ngx_int_t ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir);
 #define ngx_open_dir_n           "opendir()"
 
diff --git a/src/os/win32/ngx_files.c b/src/os/win32/ngx_files.c
index 55d7f76..0b131b5 100644
--- a/src/os/win32/ngx_files.c
+++ b/src/os/win32/ngx_files.c
@@ -427,16 +427,31 @@
 ngx_int_t
 ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir)
 {
-    ngx_cpystrn(name->data + name->len, NGX_DIR_MASK, NGX_DIR_MASK_LEN + 1);
+    u_char     *pattern, *p;
+    ngx_err_t   err;
 
-    dir->dir = FindFirstFile((const char *) name->data, &dir->finddata);
-
-    name->data[name->len] = '\0';
-
-    if (dir->dir == INVALID_HANDLE_VALUE) {
+    pattern = malloc(name->len + 3);
+    if (pattern == NULL) {
         return NGX_ERROR;
     }
 
+    p = ngx_cpymem(pattern, name->data, name->len);
+
+    *p++ = '/';
+    *p++ = '*';
+    *p = '\0';
+
+    dir->dir = FindFirstFile((const char *) pattern, &dir->finddata);
+
+    if (dir->dir == INVALID_HANDLE_VALUE) {
+        err = ngx_errno;
+        ngx_free(pattern);
+        ngx_set_errno(err);
+        return NGX_ERROR;
+    }
+
+    ngx_free(pattern);
+
     dir->valid_info = 1;
     dir->ready = 1;
 
diff --git a/src/os/win32/ngx_files.h b/src/os/win32/ngx_files.h
index 895daea..6eb720e 100644
--- a/src/os/win32/ngx_files.h
+++ b/src/os/win32/ngx_files.h
@@ -181,9 +181,6 @@
 #define NGX_HAVE_MAX_PATH           1
 #define NGX_MAX_PATH                MAX_PATH
 
-#define NGX_DIR_MASK                (u_char *) "/*"
-#define NGX_DIR_MASK_LEN            2
-
 
 ngx_int_t ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir);
 #define ngx_open_dir_n              "FindFirstFile()"