![]() |
Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
|
#include <os-canon-path.hh>
Classes | |
| class | Iterator |
Public Member Functions | |
| OsCanonPath ()=default | |
| OsCanonPath (OsFilename name) | |
| OsCanonPath (const CanonPath &canonPath) | |
| CanonPath | toPortable () const |
| const std::filesystem::path & | path () const noexcept |
| const std::filesystem::path::value_type * | c_str () const noexcept |
| bool | empty () const noexcept |
| void | pop () |
| std::optional< OsCanonPath > | parent () const |
| bool | isWithin (const OsCanonPath &prefix) const |
| OsCanonPath | removePrefix (const OsCanonPath &prefix) const |
| Iterator | begin () const |
| Iterator | end () const |
| auto | operator<=> (const OsCanonPath &) const =default |
| OsCanonPath | operator/ (const OsCanonPath &other) const |
| OsCanonPath | operator/ (const OsFilename &name) const |
Static Public Member Functions | |
| static OsCanonPath | fromPathAsserting (std::filesystem::path p) |
Friends | |
| OsCanonPath | operator/ (const OsFilename &name, const OsCanonPath &path) |
| OsCanonPath | operator/ (const OsFilename &a, const OsFilename &b) |
A newtype around std::filesystem::path that asserts at construction time that the path is a canonical relative path suitable for use with openat and Windows NT equivalents.
A valid OsCanonPath:
Unlike CanonPath, which normalizes its input, OsCanonPath asserts that the input is already canonical. Unlike CanonPath which is a virtual Unix-style path wrapping std::string, OsCanonPath wraps std::filesystem::path and respects OS-native directory separators.
|
default |
Construct the empty OsCanonPath, representing the identity path "".
|
inline |
Construct an OsCanonPath from an OsFilename.
This is always valid since a single filename component is trivially a canonical relative path.
| nix::OsCanonPath::OsCanonPath | ( | const CanonPath & | canonPath | ) |
Construct an OsCanonPath from a CanonPath.
Builds the path component-by-component using std::filesystem::path::operator/, which produces the correct OS-native directory separator.
|
inlinenoexcept |
Whether this is the empty path.
|
inlinestatic |
Construct an OsCanonPath from a path, asserting that it is already in canonical relative form. Fails with an assertion otherwise.
| bool nix::OsCanonPath::isWithin | ( | const OsCanonPath & | prefix | ) | const |
Whether prefix is this path or an ancestor of it.
| OsCanonPath nix::OsCanonPath::operator/ | ( | const OsCanonPath & | other | ) | const |
Concatenate two OsCanonPaths.
| OsCanonPath nix::OsCanonPath::operator/ | ( | const OsFilename & | name | ) | const |
Append an OsFilename to an OsCanonPath.
| std::optional< OsCanonPath > nix::OsCanonPath::parent | ( | ) | const |
Everything but the last component, or std::nullopt if this path is empty.
| void nix::OsCanonPath::pop | ( | ) |
Remove the last component. Panics if this path is empty.
| OsCanonPath nix::OsCanonPath::removePrefix | ( | const OsCanonPath & | prefix | ) | const |
Reinterpret this path as relative to prefix rather than to whatever it was relative to before.
| CanonPath nix::OsCanonPath::toPortable | ( | ) | const |
Convert back to the portable CanonPath, the inverse of the constructor above.
Structurally this round-trips: OsCanonPath invariants mean every component is a plain filename, which is exactly what CanonPath accepts, so no component is dropped or renormalized.
|
friend |
Concatenate two OsFilenames into an OsCanonPath.
This explicit overload is needed because OsFilename / OsFilename would otherwise be ambiguous between converting the LHS or RHS.
|
friend |
Prepend: OsFilename / OsCanonPath.