walk_dir_tree()
#
The walk_dir_tree()
function traverses a directory tree starting from root_dir
, applying a user-defined callback function cb
to each file or directory that matches the specified pattern
and opt
options.
Prototype
int walk_dir_tree(
hgobj gobj,
const char *root_dir,
const char *pattern,
wd_option opt,
walkdir_cb cb,
void *user_data
);
Parameters
Key |
Type |
Description |
---|---|---|
|
|
A handle to the Yuneta framework object, used for logging and error handling. |
|
|
The root directory from which the traversal begins. |
|
|
A regular expression pattern to match file or directory names. |
|
|
Options controlling the traversal behavior, such as recursion, hidden file inclusion, and file type matching. |
|
|
A callback function that is invoked for each matching file or directory. |
|
|
A user-defined pointer passed to the callback function. |
Return Value
Returns 0 on success, or -1 if an error occurs (e.g., if root_dir
does not exist or pattern
is invalid).
Notes
The callback function cb
should return TRUE
to continue traversal or FALSE
to stop. The function uses regcomp()
to compile the pattern
and regexec()
to match file names.
Prototype
// Not applicable in JS
Prototype
# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples