dpkg 1.21.11
Data Structures | Typedefs | Enumerations | Functions
Directory tree walking
Collaboration diagram for Directory tree walking:

Data Structures

struct  treewalk_funcs
 

Typedefs

typedef int treenode_visit_func(struct treenode *node)
 
typedef bool treenode_skip_func(struct treenode *node)
 
typedef int treenode_sort_func(struct treenode *node)
 

Enumerations

enum  treewalk_options { TREEWALK_NONE = 0 , TREEWALK_FORCE_STAT = DPKG_BIT(0) , TREEWALK_FOLLOW_LINKS = DPKG_BIT(1) }
 

Functions

struct treeroottreewalk_open (const char *rootdir, enum treewalk_options options, const struct treewalk_funcs *funcs)
 Open a new tree to be walked. More...
 
struct treenodetreewalk_node (struct treeroot *tree)
 Return the current node. More...
 
struct treenodetreewalk_next (struct treeroot *tree)
 Return the next node. More...
 
void treewalk_close (struct treeroot *tree)
 Closes the tree being walked. More...
 
int treewalk (const char *rootdir, enum treewalk_options options, struct treewalk_funcs *funcs)
 Tree walker. More...
 
struct treenodetreenode_get_parent (struct treenode *node)
 
const char * treenode_get_name (struct treenode *node)
 
const char * treenode_get_pathname (struct treenode *node)
 
const char * treenode_get_virtname (struct treenode *node)
 
mode_t treenode_get_mode (struct treenode *node)
 
struct stat * treenode_get_stat (struct treenode *node)
 

Detailed Description

Typedef Documentation

◆ treenode_skip_func

typedef bool treenode_skip_func(struct treenode *node)

◆ treenode_sort_func

typedef int treenode_sort_func(struct treenode *node)

◆ treenode_visit_func

typedef int treenode_visit_func(struct treenode *node)

Enumeration Type Documentation

◆ treewalk_options

Enumerator
TREEWALK_NONE 
TREEWALK_FORCE_STAT 
TREEWALK_FOLLOW_LINKS 

Function Documentation

◆ treenode_get_mode()

mode_t treenode_get_mode ( struct treenode node)

References treenode::mode.

◆ treenode_get_name()

const char * treenode_get_name ( struct treenode node)

References treenode::name.

◆ treenode_get_parent()

struct treenode * treenode_get_parent ( struct treenode node)

References treenode::up.

◆ treenode_get_pathname()

const char * treenode_get_pathname ( struct treenode node)

References treenode::pathname.

◆ treenode_get_stat()

struct stat * treenode_get_stat ( struct treenode node)

◆ treenode_get_virtname()

const char * treenode_get_virtname ( struct treenode node)

References treenode::virtname.

◆ treewalk()

int treewalk ( const char *  rootdir,
enum treewalk_options  options,
struct treewalk_funcs func 
)

Tree walker.

Parameters
rootdirThe root directory to start walking the tree.
optionsThe options specifying how to walk the tree.
funcThe function callbacks.

References treewalk_next(), treewalk_node(), and treewalk_open().

Here is the call graph for this function:

◆ treewalk_close()

void treewalk_close ( struct treeroot tree)

Closes the tree being walked.

It will free any resources previously allocated.

◆ treewalk_next()

struct treenode * treewalk_next ( struct treeroot tree)

Return the next node.

This function works basically as an iterator. And will return NULL when the whole tree has been traversed. When starting it will skip the root node, so you might want to use treewalk_node() to get that, otherwise you could use it like this:

struct treeroot *tree;
struct treenode *node;
tree = treewalk_open(...);
while ((node = treewalk_next(tree))
visitor(node);
struct treeroot * treewalk_open(const char *rootdir, enum treewalk_options options, const struct treewalk_funcs *func)
Open a new tree to be walked.
Definition: treewalk.c:365
void treewalk_close(struct treeroot *tree)
Closes the tree being walked.
Definition: treewalk.c:514
struct treenode * treewalk_next(struct treeroot *tree)
Return the next node.
Definition: treewalk.c:436
Definition: treewalk.c:40
Definition: treewalk.c:297
Parameters
treeThe tree structure.

References treeroot::curnode, and treeroot::rootnode.

Referenced by treewalk().

Here is the caller graph for this function:

◆ treewalk_node()

struct treenode * treewalk_node ( struct treeroot tree)

Return the current node.

This function is only needed if you want to start walking the tree from the root node. With something like:

struct treeroot *tree;
struct treenode *node;
tree = treewalk_open(...);
for (node = treewalk_node(tree); node; node = treewalk_next(tree))
visitor(node);
struct treenode * treewalk_node(struct treeroot *tree)
Return the current node.
Definition: treewalk.c:410
Parameters
treeThe tree structure.

References treeroot::curnode.

Referenced by treewalk().

Here is the caller graph for this function:

◆ treewalk_open()

struct treeroot * treewalk_open ( const char *  rootdir,
enum treewalk_options  options,
const struct treewalk_funcs func 
)

Open a new tree to be walked.

Parameters
rootdirThe root directory to start walking the tree.
optionsThe options specifying how to walk the tree.
funcThe functions callbacks.

References treeroot::func, m_malloc(), and treeroot::options.

Referenced by treewalk().

Here is the call graph for this function:
Here is the caller graph for this function: