add size, access, and mtime to ngx_walk_tree()
diff --git a/src/core/ngx_file.c b/src/core/ngx_file.c
index 2c365a8..4be17ec 100644
--- a/src/core/ngx_file.c
+++ b/src/core/ngx_file.c
@@ -445,8 +445,8 @@
prev = ctx->data;
- if (ctx->size) {
- data = ngx_alloc(ctx->size, ctx->log);
+ if (ctx->alloc) {
+ data = ngx_alloc(ctx->alloc, ctx->log);
if (data == NULL) {
goto failed;
}
@@ -529,6 +529,10 @@
ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->log, 0,
"tree file \"%s\"", file.data);
+ ctx->size = ngx_de_size(&dir);
+ ctx->access = ngx_de_access(&dir);
+ ctx->mtime = ngx_de_mtime(&dir);
+
if (ctx->file_handler(ctx, &file) == NGX_ABORT) {
goto failed;
}
@@ -538,6 +542,9 @@
ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->log, 0,
"tree enter dir \"%s\"", file.data);
+ ctx->access = ngx_de_access(&dir);
+ ctx->mtime = ngx_de_mtime(&dir);
+
if (ctx->pre_tree_handler(ctx, &file) == NGX_ABORT) {
goto failed;
}
@@ -546,6 +553,9 @@
goto failed;
}
+ ctx->access = ngx_de_access(&dir);
+ ctx->mtime = ngx_de_mtime(&dir);
+
if (ctx->post_tree_handler(ctx, &file) == NGX_ABORT) {
goto failed;
}
@@ -571,7 +581,7 @@
ngx_free(buf.data);
}
- if (ctx->data) {
+ if (ctx->alloc) {
ngx_free(ctx->data);
ctx->data = prev;
}
diff --git a/src/core/ngx_file.h b/src/core/ngx_file.h
index f8107ae..80dbd33 100644
--- a/src/core/ngx_file.h
+++ b/src/core/ngx_file.h
@@ -58,18 +58,23 @@
typedef struct ngx_tree_ctx_s ngx_tree_ctx_t;
-typedef ngx_int_t (*ngx_tree_init_handler_pt) (ngx_tree_ctx_t *ctx,
- ngx_tree_ctx_t *prev);
+typedef ngx_int_t (*ngx_tree_init_handler_pt) (void *ctx, void *prev);
typedef ngx_int_t (*ngx_tree_handler_pt) (ngx_tree_ctx_t *ctx, ngx_str_t *name);
struct ngx_tree_ctx_s {
+ off_t size;
+ ngx_uint_t access;
+ time_t mtime;
+
ngx_tree_init_handler_pt init_handler;
ngx_tree_handler_pt file_handler;
ngx_tree_handler_pt pre_tree_handler;
ngx_tree_handler_pt post_tree_handler;
ngx_tree_handler_pt spec_handler;
+
void *data;
- size_t size;
+ size_t alloc;
+
ngx_log_t *log;
};
diff --git a/src/http/modules/ngx_http_dav_module.c b/src/http/modules/ngx_http_dav_module.c
index 0d3c912..ad673f5 100644
--- a/src/http/modules/ngx_http_dav_module.c
+++ b/src/http/modules/ngx_http_dav_module.c
@@ -19,8 +19,7 @@
static ngx_int_t ngx_http_dav_handler(ngx_http_request_t *r);
-static ngx_int_t ngx_http_dav_no_init(ngx_tree_ctx_t *ctx,
- ngx_tree_ctx_t *prev);
+static ngx_int_t ngx_http_dav_no_init(void *ctx, void *prev);
static ngx_int_t ngx_http_dav_noop(ngx_tree_ctx_t *ctx, ngx_str_t *path);
static ngx_int_t ngx_http_dav_delete_dir(ngx_tree_ctx_t *ctx, ngx_str_t *path);
static ngx_int_t ngx_http_dav_delete_file(ngx_tree_ctx_t *ctx, ngx_str_t *path);
@@ -190,7 +189,7 @@
tree.post_tree_handler = ngx_http_dav_delete_dir;
tree.spec_handler = ngx_http_dav_delete_file;
tree.data = NULL;
- tree.size = 0;
+ tree.alloc = 0;
tree.log = r->connection->log;
if (ngx_walk_tree(&tree, &path) == NGX_OK) {
@@ -270,7 +269,7 @@
static ngx_int_t
-ngx_http_dav_no_init(ngx_tree_ctx_t *ctx, ngx_tree_ctx_t *prev)
+ngx_http_dav_no_init(void *ctx, void *prev)
{
return NGX_OK;
}