aboutsummaryrefslogtreecommitdiff
path: root/src/libutil
diff options
context:
space:
mode:
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/canon-path.cc5
-rw-r--r--src/libutil/canon-path.hh2
2 files changed, 7 insertions, 0 deletions
diff --git a/src/libutil/canon-path.cc b/src/libutil/canon-path.cc
index ddf6db6d1..040464532 100644
--- a/src/libutil/canon-path.cc
+++ b/src/libutil/canon-path.cc
@@ -13,6 +13,11 @@ CanonPath::CanonPath(std::string_view raw, const CanonPath & root)
: path(absPath((Path) raw, root.abs()))
{ }
+CanonPath CanonPath::fromCwd(std::string_view path)
+{
+ return CanonPath(unchecked_t(), absPath((Path) path));
+}
+
std::optional<CanonPath> CanonPath::parent() const
{
if (isRoot()) return std::nullopt;
diff --git a/src/libutil/canon-path.hh b/src/libutil/canon-path.hh
index 614883c06..eefe05ed5 100644
--- a/src/libutil/canon-path.hh
+++ b/src/libutil/canon-path.hh
@@ -46,6 +46,8 @@ public:
: path(std::move(path))
{ }
+ static CanonPath fromCwd(std::string_view path = ".");
+
static CanonPath root;
/**