Mercurial > hg > nginx
comparison src/os/win32/ngx_files.c @ 7433:061ec464813f
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.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 24 Dec 2018 21:07:05 +0300 |
parents | 577628e6b6a6 |
children | ccb5ff87ab3e |
comparison
equal
deleted
inserted
replaced
7432:ecc97cb0eda4 | 7433:061ec464813f |
---|---|
425 | 425 |
426 | 426 |
427 ngx_int_t | 427 ngx_int_t |
428 ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir) | 428 ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir) |
429 { | 429 { |
430 ngx_cpystrn(name->data + name->len, NGX_DIR_MASK, NGX_DIR_MASK_LEN + 1); | 430 u_char *pattern, *p; |
431 | 431 ngx_err_t err; |
432 dir->dir = FindFirstFile((const char *) name->data, &dir->finddata); | 432 |
433 | 433 pattern = malloc(name->len + 3); |
434 name->data[name->len] = '\0'; | 434 if (pattern == NULL) { |
435 return NGX_ERROR; | |
436 } | |
437 | |
438 p = ngx_cpymem(pattern, name->data, name->len); | |
439 | |
440 *p++ = '/'; | |
441 *p++ = '*'; | |
442 *p = '\0'; | |
443 | |
444 dir->dir = FindFirstFile((const char *) pattern, &dir->finddata); | |
435 | 445 |
436 if (dir->dir == INVALID_HANDLE_VALUE) { | 446 if (dir->dir == INVALID_HANDLE_VALUE) { |
437 return NGX_ERROR; | 447 err = ngx_errno; |
438 } | 448 ngx_free(pattern); |
449 ngx_set_errno(err); | |
450 return NGX_ERROR; | |
451 } | |
452 | |
453 ngx_free(pattern); | |
439 | 454 |
440 dir->valid_info = 1; | 455 dir->valid_info = 1; |
441 dir->ready = 1; | 456 dir->ready = 1; |
442 | 457 |
443 return NGX_OK; | 458 return NGX_OK; |