MCPcopy Create free account
hub / github.com/NatLabRockies/EnergyPlus / getProgramPath

Function getProgramPath

src/EnergyPlus/FileSystem.cc:203–228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

201 }
202
203 fs::path getProgramPath()
204 {
205 // /*
206 // * Returns the relative path to the executable file (including symlinks).
207 // *
208 // * To resolve symlinks, wrap this call in getAbsolutePath().
209 // */
210 char executableRelativePath[1024] = {'\0'};
211
212#ifdef __APPLE__
213 uint32_t pathSize = sizeof(executableRelativePath);
214 _NSGetExecutablePath(executableRelativePath, &pathSize);
215#elif __linux__
216 ssize_t len = readlink("/proc/self/exe", executableRelativePath, sizeof(executableRelativePath) - 1);
217 if (len == -1) {
218 std::cout << "ERROR: Unable to locate executable." << std::endl;
219 std::exit(EXIT_FAILURE);
220 } else {
221 executableRelativePath[len] = '\0';
222 }
223#elif _WIN32
224 GetModuleFileName(NULL, executableRelativePath, sizeof(executableRelativePath));
225#endif
226
227 return executableRelativePath;
228 }
229
230 // TODO: remove? seems like fs::path::extension would do fine. It's only used in CommandLineInterface to check the input file type, so we could
231 // just compare to ".EPJSON" instead of "EPJSON"...

Callers 8

ProcessArgsFunction · 0.85
PythonEngineMethod · 0.85
getBasicPreambleMethod · 0.85
getTclPreppedPreambleMethod · 0.85
PluginManagerMethod · 0.85
runGHEDesignerMethod · 0.85
TESTFunction · 0.85
SetUpMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected