![]() |
Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
|
#include <executable-path.hh>
Public Member Functions | |
| void | parseAppend (const OsString &path) |
| OsString | render () const |
| std::optional< std::filesystem::path > | findName (const OsString &exe, std::function< bool(const std::filesystem::path &)> isExecutableFile=isExecutableFileAmbient) const |
| std::filesystem::path | findPath (const std::filesystem::path &exe, std::function< bool(const std::filesystem::path &)> isExecutable=isExecutableFileAmbient) const |
| bool | operator== (const ExecutablePath &) const =default |
Static Public Member Functions | |
| static ExecutablePath | parse (const OsString &path) |
| static ExecutablePath | load () |
Public Attributes | |
| std::vector< std::filesystem::path > | directories |
Static Public Attributes | |
| static constexpr const OsChar | separator |
| std::optional< std::filesystem::path > nix::ExecutablePath::findName | ( | const OsString & | exe, |
| std::function< bool(const std::filesystem::path &)> | isExecutableFile = isExecutableFileAmbient ) const |
Search for an executable.
For Unix, this is according to the POSIX spec for PATH. https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03
| exe | This must just be a name, and not contain any / (or \\endiskip on Windows). in case it does, per the spec no lookup should be performed, and the path (it is not just a file name) as is. This is the caller's respsonsibility. |
This is a pure function, except for the default isExecutable argument, which uses the ambient file system to check if a file is executable (and exists).
| std::filesystem::path nix::ExecutablePath::findPath | ( | const std::filesystem::path & | exe, |
| std::function< bool(const std::filesystem::path &)> | isExecutable = isExecutableFileAmbient ) const |
Like the findName but also allows a file path as input.
This implements the full POSIX spec: if the path is just a name, it searches like the above. Otherwise, it returns the path as is. If (in the name case) the search fails, an exception is thrown.
|
static |
Load the PATH environment variable and parse it.
|
static |
Parse path into a list of paths.
On Unix we split on :, on Windows we split on ;.
For Unix, this is according to the POSIX spec for PATH. https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03
| void nix::ExecutablePath::parseAppend | ( | const OsString & | path | ) |
Like parse but appends new entries to the end of an existing ExecutablePath.
|
staticconstexpr |