1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-06 17:31:47 +02:00
This commit is contained in:
Eelco Dolstra 2023-11-14 14:47:17 +01:00
parent 7f576f5dfe
commit c257c82447
3 changed files with 17 additions and 6 deletions

View file

@ -13,6 +13,13 @@ CanonPath::CanonPath(std::string_view raw, const CanonPath & root)
: path(absPath((Path) raw, root.abs()))
{ }
CanonPath::CanonPath(const std::vector<std::string> & elems)
: path("/")
{
for (auto & s : elems)
push(s);
}
CanonPath CanonPath::fromCwd(std::string_view path)
{
return CanonPath(unchecked_t(), absPath((Path) path));

View file

@ -6,6 +6,7 @@
#include <cassert>
#include <iostream>
#include <set>
#include <vector>
namespace nix {
@ -46,6 +47,11 @@ public:
: path(std::move(path))
{ }
/**
* Construct a canon path from a vector of elements.
*/
CanonPath(const std::vector<std::string> & elems);
static CanonPath fromCwd(std::string_view path = ".");
static CanonPath root;