MCPcopy Create free account
hub / github.com/WayfireWM/wayfire / locate_executable

Function locate_executable

src/debug.cpp:135–152  ·  view source on GitHub ↗

* Try to find the correct path to the given executable. * * If the path is relative(beginning with . or ..), or absolute, we already * have the correct path. Otherwise, try to find it with 'which' */

Source from the content-addressed store, hash-verified

133 * have the correct path. Otherwise, try to find it with 'which'
134 */
135std::string locate_executable(std::string executable)
136{
137 if (!executable.length())
138 {
139 return "";
140 }
141
142 /* If absolute/relative address, we can't do anything */
143 if ((executable[0] == '/') || (executable[0] == '.'))
144 {
145 return executable;
146 }
147
148 /* If just an executable, try to find it in PATH */
149 auto path = read_output("which " + executable);
150
151 return path;
152}
153
154/**
155 * Find the first position where ".." is, and then strip everything before that.

Callers 1

locate_source_fileFunction · 0.85

Calls 1

read_outputFunction · 0.85

Tested by

no test coverage detected