MCPcopy Create free account
hub / github.com/apache/httpd / dav_fs_walker

Function dav_fs_walker

modules/dav/fs/repos.c:1537–1824  ·  view source on GitHub ↗

### move this to dav_util? */ Walk recursively down through directories, * * including lock-null resources as we go. */

Source from the content-addressed store, hash-verified

1535/* Walk recursively down through directories, *
1536 * including lock-null resources as we go. */
1537static dav_error * dav_fs_walker(dav_fs_walker_context *fsctx, int depth)
1538{
1539 const dav_walk_params *params = fsctx->params;
1540 apr_pool_t *pool = params->pool;
1541 apr_status_t status;
1542 dav_error *err = NULL;
1543 int isdir = fsctx->res1.collection;
1544 apr_finfo_t dirent;
1545 apr_dir_t *dirp;
1546
1547 /* ensure the context is prepared properly, then call the func */
1548 err = (*params->func)(&fsctx->wres,
1549 isdir
1550 ? DAV_CALLTYPE_COLLECTION
1551 : DAV_CALLTYPE_MEMBER);
1552 if (err != NULL) {
1553 return err;
1554 }
1555
1556 if (depth == 0 || !isdir) {
1557 return NULL;
1558 }
1559
1560 /* put a trailing slash onto the directory, in preparation for appending
1561 * files to it as we discovery them within the directory */
1562 dav_check_bufsize(pool, &fsctx->path1, DAV_BUFFER_PAD);
1563 fsctx->path1.buf[fsctx->path1.cur_len++] = '/';
1564 fsctx->path1.buf[fsctx->path1.cur_len] = '\0'; /* in pad area */
1565
1566 /* if a secondary path is present, then do that, too */
1567 if (fsctx->path2.buf != NULL) {
1568 dav_check_bufsize(pool, &fsctx->path2, DAV_BUFFER_PAD);
1569 fsctx->path2.buf[fsctx->path2.cur_len++] = '/';
1570 fsctx->path2.buf[fsctx->path2.cur_len] = '\0'; /* in pad area */
1571 }
1572
1573 /* Note: the URI should ALREADY have a trailing "/" */
1574
1575 /* for this first pass of files, all resources exist */
1576 fsctx->res1.exists = 1;
1577
1578 /* a file is the default; we'll adjust if we hit a directory */
1579 fsctx->res1.collection = 0;
1580 fsctx->res2.collection = 0;
1581
1582 /* open and scan the directory */
1583 if ((status = apr_dir_open(&dirp, fsctx->path1.buf, pool)) != APR_SUCCESS) {
1584 /* ### need a better error */
1585 return dav_new_error(pool, HTTP_NOT_FOUND, 0, status, NULL);
1586 }
1587 while ((apr_dir_read(&dirent, APR_FINFO_DIRENT, dirp)) == APR_SUCCESS) {
1588 apr_size_t len;
1589
1590 len = strlen(dirent.name);
1591
1592 /* avoid recursing into our current, parent, or state directories */
1593 if (dirent.name[0] == '.'
1594 && (len == 1 || (dirent.name[1] == '.' && len == 2))) {

Callers 1

dav_fs_internal_walkFunction · 0.85

Calls 5

dav_check_bufsizeFunction · 0.85
dav_new_errorFunction · 0.85
dav_buffer_place_memFunction · 0.85
dav_lock_queryFunction · 0.85

Tested by

no test coverage detected