aboutsummaryrefslogtreecommitdiff
path: root/build2
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-12-01 14:59:32 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-12-01 14:59:32 +0200
commit6cb960121c4195dd9d12c92d4f3ff2819fad143e (patch)
tree5a23232c224a1fbb4cfc38d077de65099adf7ea1 /build2
parent08eea971d2d3170ca357935644483dc520f46173 (diff)
Add path.canonicalize() function
Diffstat (limited to 'build2')
-rw-r--r--build2/functions-path.cxx24
1 files changed, 24 insertions, 0 deletions
diff --git a/build2/functions-path.cxx b/build2/functions-path.cxx
index e21609c..243f0d7 100644
--- a/build2/functions-path.cxx
+++ b/build2/functions-path.cxx
@@ -93,6 +93,30 @@ namespace build2
return r;
};
+ // canonicalize
+ //
+ f["canonicalize"] = [](path p) {p.canonicalize (); return p;};
+ f["canonicalize"] = [](dir_path p) {p.canonicalize (); return p;};
+
+ f["canonicalize"] = [](paths v) {for (auto& p: v) p.canonicalize (); return v;};
+ f["canonicalize"] = [](dir_paths v) {for (auto& p: v) p.canonicalize (); return v;};
+
+ f[".canonicalize"] = [](names ns)
+ {
+ // For each path decide based on the presence of a trailing slash
+ // whether it is a directory. Return as untyped list of (potentially
+ // mixed) paths.
+ //
+ for (name& n: ns)
+ {
+ if (n.directory ())
+ n.dir.canonicalize ();
+ else
+ n.value = convert<path> (move (n)).canonicalize ().string ();
+ }
+ return ns;
+ };
+
// normalize
//
f["normalize"] = [](path p) {p.normalize (); return p;};