Klaus Demo nginx / a13b3b9
ignore glob no match error Igor Sysoev 14 years ago
5 changed file(s) with 41 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
644644 return NGX_CONF_ERROR;
645645 }
646646
647 if (strpbrk((char *) file.data, "*?[") == NULL) {
648
649 ngx_log_debug1(NGX_LOG_DEBUG_CORE, cf->log, 0, "include %s", file.data);
650
651 return ngx_conf_parse(cf, &file);
652 }
653
647654 ngx_memzero(&gl, sizeof(ngx_glob_t));
648655
649656 gl.pattern = file.data;
650657 gl.log = cf->log;
658 gl.test = 1;
651659
652660 if (ngx_open_glob(&gl) != NGX_OK) {
653661 ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno,
256256 ngx_int_t
257257 ngx_open_glob(ngx_glob_t *gl)
258258 {
259 if (glob((char *) gl->pattern, GLOB_NOSORT, NULL, &gl->pglob) == 0) {
259 int n;
260
261 n = glob((char *) gl->pattern, GLOB_NOSORT, NULL, &gl->pglob);
262
263 if (n == 0) {
264 return NGX_OK;
265 }
266
267 if (n == GLOB_NOMATCH && gl->test) {
260268 return NGX_OK;
261269 }
262270
153153
154154
155155 typedef struct {
156 size_t n;
157 glob_t pglob;
158 u_char *pattern;
159 ngx_log_t *log;
156 size_t n;
157 glob_t pglob;
158 u_char *pattern;
159 ngx_log_t *log;
160 ngx_uint_t test;
160161 } ngx_glob_t;
161162
162163
360360 gl->dir = FindFirstFile((const char *) gl->pattern, &gl->finddata);
361361
362362 if (gl->dir == INVALID_HANDLE_VALUE) {
363
364 if (ngx_errno == ERROR_FILE_NOT_FOUND && gl->test) {
365 gl->no_match = 1;
366 return NGX_OK;
367 }
368
363369 return NGX_ERROR;
364370 }
365371
393399 size_t len;
394400 ngx_err_t err;
395401
402 if (gl->no_match) {
403 return NGX_DONE;
404 }
405
396406 if (gl->ready) {
397407 *name = gl->name;
398408
442452 ngx_free(gl->name.data);
443453 }
444454
455 if (gl->dir == INVALID_HANDLE_VALUE) {
456 return;
457 }
458
445459 if (FindClose(gl->dir) == 0) {
446460 ngx_log_error(NGX_LOG_ALERT, gl->log, ngx_errno,
447461 "FindClose(%s) failed", gl->pattern);
183183 typedef struct {
184184 HANDLE dir;
185185 WIN32_FIND_DATA finddata;
186 ngx_int_t ready;
186
187 unsigned ready:1;
188 unsigned test:1;
189 unsigned no_match:1;
190
187191 u_char *pattern;
188192 ngx_str_t name;
189193 size_t last;