|
Nix 2.93.3
Lix: A modern, delicious implementation of the Nix package manager; unstable internal interfaces
|
#include <canon-path.hh>
Classes | |
| struct | unchecked_t |
| struct | Iterator |
Public Member Functions | |
| CanonPath (std::string_view raw) | |
| CanonPath (const char *raw) | |
| CanonPath (unchecked_t _, std::string path) | |
| CanonPath (std::string_view raw, const CanonPath &root) | |
| bool | isRoot () const |
| operator std::string_view () const | |
| const std::string & | abs () const |
| const std::string & | absOrEmpty () const |
| const char * | c_str () const |
| std::string_view | rel () const |
| Iterator | begin () const |
| Iterator | end () const |
| std::optional< CanonPath > | parent () const |
| void | pop () |
| std::optional< std::string_view > | dirOf () const |
| std::optional< std::string_view > | baseName () const |
| bool | operator== (const CanonPath &x) const |
| bool | operator!= (const CanonPath &x) const |
| bool | operator< (const CanonPath &x) const |
| bool | isWithin (const CanonPath &parent) const |
| CanonPath | removePrefix (const CanonPath &prefix) const |
| void | extend (const CanonPath &x) |
| CanonPath | operator+ (const CanonPath &x) const |
| void | push (std::string_view c) |
| CanonPath | operator+ (std::string_view c) const |
| bool | isAllowed (const std::set< CanonPath > &allowed) const |
| std::string | makeRelative (const CanonPath &path) const |
Static Public Member Functions | |
| static CanonPath | fromCwd (std::string_view path=".") |
Static Public Attributes | |
| static CanonPath | root = CanonPath("/") |
A canonical representation of a path. It ensures the following:
Note that the path does not need to correspond to an actually existing path, and there is no guarantee that symlinks are resolved.
| nix::CanonPath::CanonPath | ( | std::string_view | raw | ) |
Construct a canon path from a non-canonical path. Any '.', '..' or empty components are removed.
| nix::CanonPath::CanonPath | ( | std::string_view | raw, |
| const CanonPath & | root ) |
If raw starts with a slash, return CanonPath(raw). Otherwise return a CanonPath representing root + "/" + raw.
|
inline |
Like abs(), but return an empty string if this path is '/'. Thus the returned string never ends in a slash.
| void nix::CanonPath::extend | ( | const CanonPath & | x | ) |
Append another path to this one.
| bool nix::CanonPath::isAllowed | ( | const std::set< CanonPath > & | allowed | ) | const |
Check whether access to this path is allowed, which is the case if 1) this is within any of the allowed paths; or 2) any of the allowed paths are within this. (The latter condition ensures access to the parents of allowed paths.)
| bool nix::CanonPath::isWithin | ( | const CanonPath & | parent | ) | const |
Return true if this is equal to parent or a child of parent.
| std::string nix::CanonPath::makeRelative | ( | const CanonPath & | path | ) | const |
Return a representation x of path relative to this, i.e. CanonPath(this.makeRelative(x), this) == path.
|
inline |
Compare paths lexicographically except that path separators are sorted before any other character. That is, in the sorted order a directory is always followed directly by its children. For instance, 'foo' < 'foo/bar' < 'foo!'.
| void nix::CanonPath::pop | ( | ) |
Remove the last component. Panics if this path is the root.
| void nix::CanonPath::push | ( | std::string_view | c | ) |
Add a path component to this one. It must not contain any slashes.