aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/functions-filesystem.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2022-12-08 21:13:47 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2022-12-12 18:28:02 +0300
commitab7dba520c8efd2cfbdd71dd91ae6b60923a12cd (patch)
treebb4cf6a252397c5aa1f0cf9ef7a3ab064b6079e6 /libbuild2/functions-filesystem.cxx
parentaeae50fe987b1787d1c1ae6f5c0bfb4f179205ef (diff)
Adapt to dir_iterator API change
Diffstat (limited to 'libbuild2/functions-filesystem.cxx')
-rw-r--r--libbuild2/functions-filesystem.cxx30
1 files changed, 26 insertions, 4 deletions
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 <libbuild2/variable.hxx>
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(<pattern> [, <start-dir>])
//
// 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<dir_path> (move (start)));
};
}
-
}
}