MCPcopy Create free account
hub / github.com/NVIDIA-RTX/Donut / GetDirectoryWithExecutable

Method GetDirectoryWithExecutable

src/app/ApplicationBase.cpp:230–251  ·  view source on GitHub ↗

XXXX mk: as of C++20, there is no portable solution (yet ?)

Source from the content-addressed store, hash-verified

228
229// XXXX mk: as of C++20, there is no portable solution (yet ?)
230std::filesystem::path donut::app::GetDirectoryWithExecutable()
231{
232
233 char path[PATH_MAX] = {0};
234#ifdef _WIN32
235 if (GetModuleFileNameA(nullptr, path, dim(path)) == 0)
236 return "";
237#else // _WIN32
238 // /proc/self/exe is mostly linux-only, but can't hurt to try it elsewhere
239 if (readlink("/proc/self/exe", path, std::size(path)) <= 0)
240 {
241 // portable but assumes executable dir == cwd
242 if (!getcwd(path, std::size(path)))
243 return ""; // failure
244 }
245#endif // _WIN32
246
247 std::filesystem::path result = path;
248 result = result.parent_path();
249
250 return result;
251}
252
253nvrhi::GraphicsAPI donut::app::GetGraphicsAPIFromCommandLine(int argc, const char* const* argv)
254{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected