Lines Matching refs:node
24 // Create a dirtree node from a path, with stat and symlink info.
35 // open code this because haven't got node to call dirtree_parentfd() on yet
73 // Return path to this node, assembled recursively.
79 char *dirtree_path(struct dirtree *node, int *plen)
84 if (!node) {
90 len = (plen ? *plen : 0)+strlen(node->name)+1;
91 path = dirtree_path(node->parent, &len);
93 len = stpcpy(path+len, node->name) - path;
99 int dirtree_parentfd(struct dirtree *node)
101 return node->parent ? node->parent->dirfd : AT_FDCWD;
104 // Handle callback for a node in the tree. Returns saved node(s) if
106 // returns NULL. If !callback return top node unchanged.
110 int (*callback)(struct dirtree *node))
131 // Recursively read/process children of directory node, filtering through
134 int dirtree_recurse(struct dirtree *node,
135 int (*callback)(struct dirtree *node), int dirfd, int flags)
137 struct dirtree *new, **ddt = &(node->child);
141 node->dirfd = dirfd;
142 if (node->dirfd == -1 || !(dir = fdopendir(node->dirfd))) {
144 char *path = dirtree_path(node, 0);
148 close(node->dirfd);
159 if (!(new = dirtree_add_node(node, entry->d_name, flags))) continue;
171 node->again |= 1;
172 flags = callback(node);
177 node->dirfd = -1;
183 // return just the top node. Use dirtree_notdotdot callback to allocate a
184 // tree of struct dirtree nodes and return pointer to root node for later
190 int (*callback)(struct dirtree *node))
196 struct dirtree *dirtree_read(char *path, int (*callback)(struct dirtree *node))