MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / findInSystemPath

Function findInSystemPath

src/utilities/core/PathHelpers.cpp:205–235  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203}
204
205path findInSystemPath(const path& p) {
206
207 path result;
208 // Ensure that this is just a name and not a path
209 if (p.parent_path().empty()) {
210 std::istringstream pathstream(getenv("PATH"));
211 LOG_FREE(Debug, "PathHelpers", "findInSystemPath, searching for '" << p << "' in PATH'");
212
213 std::string pathstring;
214 while (std::getline(pathstream, pathstring, pathDelimiter())) {
215 LOG_FREE(Trace, "PathHelpers", "findInSystemPath, searching for '" << p << "' in '" << pathstring << "'");
216
217 auto maybepath = toPath(pathstring) / p;
218 if (openstudio::filesystem::exists(maybepath) && !openstudio::filesystem::is_directory(maybepath)) {
219 LOG_FREE(Debug, "PathHelpers", "findInSystemPath, found '" << p << "' in PATH: '" << pathstring);
220 result = maybepath;
221 break;
222 }
223 }
224 if (result.empty()) {
225 LOG_FREE(Debug, "PathHelpers", "findInSystemPath, p wasn't found in PATH, leaving as is");
226 result = p;
227 }
228
229 } else {
230 LOG_FREE(Debug, "PathHelpers", "findInSystemPath, p isn't just a name, leaving as is");
231 result = p;
232 }
233
234 return result;
235}
236
237path completeAndNormalize(const path& p) {
238

Callers 1

TESTFunction · 0.85

Calls 3

pathDelimiterFunction · 0.85
toPathFunction · 0.70
emptyMethod · 0.45

Tested by 1

TESTFunction · 0.68