From 59e17afe291f9df52d2334b92e88a889c2fe8f6a Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Tue, 11 Jul 2023 13:08:06 +0200 Subject: cftw: Allow user callback to stop recursive search So far, cftw would search through all directories and files recursively, until all objects are processed. However, it is interesting for the user callback to be able to stop this process under specific circumstances. Now, cftw will pass a pointer to a bool, initialised to false by default, that can be optionally assigned to true by the user callback. Future commits will make use of this feature. For example, this will be used to limit the number of search results when a user enters a search term that is too generic and would otherwise generate a large amount of search results. --- cftw.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'cftw.h') diff --git a/cftw.h b/cftw.h index 612451e..663960c 100644 --- a/cftw.h +++ b/cftw.h @@ -1,11 +1,12 @@ #ifndef CFTW_H #define CFTW_H +#include #include /* Thread-safe variant of ftw(3) and nftw(3) that allows passing an * opaque pointer and removes some unneeded parameters. */ int cftw(const char *dirpath, int (*fn)(const char *fpath, - const struct stat *sb, void *user), void *user); + const struct stat *sb, bool *done, void *user), void *user); #endif /* CFTW_H */ -- cgit v1.2.3