From ab7dba520c8efd2cfbdd71dd91ae6b60923a12cd Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 8 Dec 2022 21:13:47 +0300 Subject: Adapt to dir_iterator API change --- libbuild2/functions-filesystem.cxx | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'libbuild2/functions-filesystem.cxx') diff --git a/libbuild2/functions-filesystem.cxx b/libbuild2/functions-filesystem.cxx index ef7bfc5..1acb3d1 100644 --- a/libbuild2/functions-filesystem.cxx +++ b/libbuild2/functions-filesystem.cxx @@ -7,6 +7,7 @@ #include using namespace std; +using namespace butl; namespace build2 { @@ -29,12 +30,27 @@ namespace build2 return true; }; + auto dangling = [] (const dir_entry& de) + { + bool sl (de.ltype () == entry_type::symlink); + + warn << "skipping " + << (sl ? "dangling symlink" : "inaccessible entry") << ' ' + << de.base () / de.path (); + + return true; + }; + // Print paths "as is" in the diagnostics. // try { if (pattern.absolute ()) - path_search (pattern, add); + path_search (pattern, + add, + dir_path () /* start */, + path_match_flags::follow_symlinks, + dangling); else { // An absolute start directory must be specified for the relative @@ -54,7 +70,11 @@ namespace build2 << "' is relative"; } - path_search (pattern, add, *start); + path_search (pattern, + add, + *start, + path_match_flags::follow_symlinks, + dangling); } } catch (const system_error& e) @@ -83,7 +103,7 @@ namespace build2 function_family f (m, "filesystem"); - // path_search + // $path_search( [, ]) // // Return filesystem paths that match the pattern. If the pattern is an // absolute path, then the start directory is ignored (if present). @@ -91,6 +111,9 @@ namespace build2 // // Note that this function is not pure. // + // @@ In the future we may want to add a flag that controls the + // dangling/inaccessible treatment. + // { auto e (f.insert ("path_search", false)); @@ -115,6 +138,5 @@ namespace build2 convert (move (start))); }; } - } } -- cgit v1.1