Klaus Demo nginx / f5a359b
add size, access, and mtime to ngx_walk_tree() Igor Sysoev 15 years ago
3 changed file(s) with 24 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
444444
445445 prev = ctx->data;
446446
447 if (ctx->size) {
448 data = ngx_alloc(ctx->size, ctx->log);
447 if (ctx->alloc) {
448 data = ngx_alloc(ctx->alloc, ctx->log);
449449 if (data == NULL) {
450450 goto failed;
451451 }
528528 ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->log, 0,
529529 "tree file \"%s\"", file.data);
530530
531 ctx->size = ngx_de_size(&dir);
532 ctx->access = ngx_de_access(&dir);
533 ctx->mtime = ngx_de_mtime(&dir);
534
531535 if (ctx->file_handler(ctx, &file) == NGX_ABORT) {
532536 goto failed;
533537 }
537541 ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->log, 0,
538542 "tree enter dir \"%s\"", file.data);
539543
544 ctx->access = ngx_de_access(&dir);
545 ctx->mtime = ngx_de_mtime(&dir);
546
540547 if (ctx->pre_tree_handler(ctx, &file) == NGX_ABORT) {
541548 goto failed;
542549 }
545552 goto failed;
546553 }
547554
555 ctx->access = ngx_de_access(&dir);
556 ctx->mtime = ngx_de_mtime(&dir);
557
548558 if (ctx->post_tree_handler(ctx, &file) == NGX_ABORT) {
549559 goto failed;
550560 }
570580 ngx_free(buf.data);
571581 }
572582
573 if (ctx->data) {
583 if (ctx->alloc) {
574584 ngx_free(ctx->data);
575585 ctx->data = prev;
576586 }
5757
5858 typedef struct ngx_tree_ctx_s ngx_tree_ctx_t;
5959
60 typedef ngx_int_t (*ngx_tree_init_handler_pt) (ngx_tree_ctx_t *ctx,
61 ngx_tree_ctx_t *prev);
60 typedef ngx_int_t (*ngx_tree_init_handler_pt) (void *ctx, void *prev);
6261 typedef ngx_int_t (*ngx_tree_handler_pt) (ngx_tree_ctx_t *ctx, ngx_str_t *name);
6362
6463 struct ngx_tree_ctx_s {
64 off_t size;
65 ngx_uint_t access;
66 time_t mtime;
67
6568 ngx_tree_init_handler_pt init_handler;
6669 ngx_tree_handler_pt file_handler;
6770 ngx_tree_handler_pt pre_tree_handler;
6871 ngx_tree_handler_pt post_tree_handler;
6972 ngx_tree_handler_pt spec_handler;
73
7074 void *data;
71 size_t size;
75 size_t alloc;
76
7277 ngx_log_t *log;
7378 };
7479
1818
1919
2020 static ngx_int_t ngx_http_dav_handler(ngx_http_request_t *r);
21 static ngx_int_t ngx_http_dav_no_init(ngx_tree_ctx_t *ctx,
22 ngx_tree_ctx_t *prev);
21 static ngx_int_t ngx_http_dav_no_init(void *ctx, void *prev);
2322 static ngx_int_t ngx_http_dav_noop(ngx_tree_ctx_t *ctx, ngx_str_t *path);
2423 static ngx_int_t ngx_http_dav_delete_dir(ngx_tree_ctx_t *ctx, ngx_str_t *path);
2524 static ngx_int_t ngx_http_dav_delete_file(ngx_tree_ctx_t *ctx, ngx_str_t *path);
189188 tree.post_tree_handler = ngx_http_dav_delete_dir;
190189 tree.spec_handler = ngx_http_dav_delete_file;
191190 tree.data = NULL;
192 tree.size = 0;
191 tree.alloc = 0;
193192 tree.log = r->connection->log;
194193
195194 if (ngx_walk_tree(&tree, &path) == NGX_OK) {
269268
270269
271270 static ngx_int_t
272 ngx_http_dav_no_init(ngx_tree_ctx_t *ctx, ngx_tree_ctx_t *prev)
271 ngx_http_dav_no_init(void *ctx, void *prev)
273272 {
274273 return NGX_OK;
275274 }