Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dirwalk interface to libutil, update readdir callers #1059

merged 7 commits into from May 13, 2017


None yet
3 participants
Copy link

grondo commented May 13, 2017

This PR adds a new "dirwalk" class to libutil, encapsulating a common case of recursively walking a directory tree. dirwalk is like a simplified ftw(3), however it allows the passing of a user context so results can be collected without the use of globals.

Since recursive directory search of a colon-separated path may be a common case, a dirwalk_find wrapper around dirwalk is also provided, which passes all entries that match a glob pattern to the user callback, and collects marked paths in a zlist_t on behalf of the user.

This may be a bit of overkill, but it was hard to stop once I started collecting common code together.

Current users of readdir were also updated to the new interface.

Fixes #1054

grondo added some commits May 13, 2017

libutil/dirwalk: add recursive directory walker
Add new dirwalk class to recursively walk directory trees with
a user-provided visitor function. Based on ftw(), dirwalk()
is slightly simpler, and allows a user context to be passed along
during the file tree walk, for accumulation results, counts, or
other objects that might be necessary during the walk (without
requiring the use of globals.)
libutil/unlink_recursive: use dirwalk
Update unlink_recursive() to use dirwalk().
libflux/handle: use dirwalk_find in find_file
Use dirwalk_find instead of custom directory search in handle.c
libflux/module: use dirwalk in flux_modfind
Update flux_modfind to use dirwalk for recursive directory walk
instead of custom readdir loop.

This comment has been minimized.

Copy link

garlick commented May 13, 2017


This comment has been minimized.

Copy link

coveralls commented May 13, 2017

Coverage Status

Coverage increased (+0.04%) to 77.992% when pulling 599d873 on grondo:dirwalk into 3ed906c on flux-framework:master.


This comment has been minimized.

Copy link

garlick commented May 13, 2017

Looks great, and nice job on the test coverage.

@garlick garlick merged commit 9c78848 into flux-framework:master May 13, 2017

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
coverage/coveralls Coverage increased (+0.04%) to 77.992%

This comment has been minimized.

Copy link
Contributor Author

grondo commented May 14, 2017


@grondo grondo deleted the grondo:dirwalk branch May 14, 2017

@grondo grondo referenced this pull request Aug 23, 2017


0.8.0 Release #1160

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.