diff options
Diffstat (limited to 'lib/util/src')
-rw-r--r-- | lib/util/src/dir_tree_iterator.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/util/src/dir_tree_iterator.c b/lib/util/src/dir_tree_iterator.c index 55fbabb..a63209b 100644 --- a/lib/util/src/dir_tree_iterator.c +++ b/lib/util/src/dir_tree_iterator.c @@ -216,6 +216,23 @@ retry: } } + if (it->cfg.name_pattern != NULL) { + if (it->cfg.flags & DIR_SCAN_MATCH_FULL_PATH) { + ret = fnmatch(it->cfg.name_pattern, + ent->name, FNM_PATHNAME); + } else { + const char *name = strrchr(ent->name, '/'); + name = (name == NULL) ? ent->name : (name + 1); + + ret = fnmatch(it->cfg.name_pattern, name, 0); + } + + if (ret != 0) { + free(ent); + goto retry; + } + } + *out = ent; return it->state; fail: |