#include <executable-path.hh>
|
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 |
|
|
std::vector< std::filesystem::path > | directories |
|
- Todo
- rename, it is not just good for execuatable paths, but also other lists of paths.
◆ findName()
std::optional< fs::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
- Parameters
-
exe | This must just be a name, and not contain any / (or \ on Windows). in case it does, per the spec no lookup should be perfomed, 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).
- Returns
- path to a resolved executable
◆ findPath()
fs::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.
◆ load()
Load the PATH
environment variable and parse
it.
◆ parse()
◆ render()
OsString nix::ExecutablePath::render |
( |
| ) |
const |
◆ separator
const OsChar nix::ExecutablePath::separator |
|
staticconstexpr |
The documentation for this struct was generated from the following files:
- /home/buildozer/aports/community/nix/src/nix-2.26.3/src/libutil/executable-path.hh
- /home/buildozer/aports/community/nix/src/nix-2.26.3/src/libutil/executable-path.cc