From fda29616c7af6b6e2a79c596cc01123a2d68ee02 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 1 Nov 2018 21:46:50 -0400 Subject: Implement a depth-first mode (-dfs) --- bftw.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'bftw.h') diff --git a/bftw.h b/bftw.h index 6f5ad6d..f9d1aa0 100644 --- a/bftw.h +++ b/bftw.h @@ -189,6 +189,16 @@ enum bftw_flags { BFTW_XDEV = 1 << 6, }; +/** + * Tree search strategies for bftw(). + */ +enum bftw_strategy { + /** Breadth-first search. */ + BFTW_BFS, + /** Depth-first search. */ + BFTW_DFS, +}; + /** * Structure for holding the arguments passed to bftw(). */ @@ -205,6 +215,8 @@ struct bftw_args { int nopenfd; /** Flags that control bftw() behaviour. */ enum bftw_flags flags; + /** The search strategy to use. */ + enum bftw_strategy strategy; /** The parsed mount table, if available. */ const struct bfs_mtab *mtab; }; @@ -213,8 +225,7 @@ struct bftw_args { * Breadth First Tree Walk (or Better File Tree Walk). * * Like ftw(3) and nftw(3), this function walks a directory tree recursively, - * and invokes a callback for each path it encounters. However, bftw() operates - * breadth-first. + * and invokes a callback for each path it encounters. * * @param args * The arguments that control the walk. -- cgit v1.2.3