Mercurial > hg > nginx
diff src/os/win32/ngx_files.c @ 727:532d15ddbe68
glob support in include
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 02 Oct 2006 08:46:45 +0000 |
parents | 7e24168b0853 |
children | 25114f8e2780 |
line wrap: on
line diff
--- a/src/os/win32/ngx_files.c +++ b/src/os/win32/ngx_files.c @@ -301,7 +301,7 @@ ngx_open_dir(ngx_str_t *name, ngx_dir_t { ngx_cpystrn(name->data + name->len, NGX_DIR_MASK, NGX_DIR_MASK_LEN + 1); - dir->dir = FindFirstFile((const char *) name->data, &dir->fd); + dir->dir = FindFirstFile((const char *) name->data, &dir->finddata); if (dir->dir == INVALID_HANDLE_VALUE) { return NGX_ERROR; @@ -322,7 +322,7 @@ ngx_read_dir(ngx_dir_t *dir) return NGX_OK; } - if (FindNextFile(dir->dir, &dir->fd) != 0) { + if (FindNextFile(dir->dir, &dir->finddata) != 0) { return NGX_OK; } @@ -331,6 +331,64 @@ ngx_read_dir(ngx_dir_t *dir) ngx_int_t +ngx_open_glob(ngx_glob_t *gl) +{ + gl->dir = FindFirstFile((const char *) gl->pattern, &gl->finddata); + + if (gl->dir == INVALID_HANDLE_VALUE) { + return NGX_ERROR; + } + + gl->ready = 1; + + return NGX_OK; +} + + +ngx_int_t +ngx_read_glob(ngx_glob_t *gl, ngx_str_t *name) +{ + ngx_err_t err; + + if (gl->ready) { + name->len = ngx_strlen(gl->finddata.cFileName); + name->data = (u_char *) gl->finddata.cFileName; + + gl->ready = 0; + return NGX_OK; + } + + if (FindNextFile(gl->dir, &gl->finddata) != 0) { + name->len = ngx_strlen(gl->finddata.cFileName); + name->data = (u_char *) gl->finddata.cFileName; + + return NGX_OK; + } + + err = ngx_errno; + + if (err == NGX_ENOMOREFILES) { + return NGX_DONE; + } + + ngx_log_error(NGX_LOG_ALERT, gl->log, err, + "FindNextFile(%s) failed", gl->pattern); + + return NGX_ERROR; +} + + +void +ngx_close_glob(ngx_glob_t *gl) +{ + if (FindClose(gl->dir) != 0) { + ngx_log_error(NGX_LOG_ALERT, gl->log, ngx_errno, + "FindClose(%s) failed", gl->pattern); + } +} + + +ngx_int_t ngx_de_info(u_char *name, ngx_dir_t *dir) { return NGX_OK;