XXXX mk: as of C++20, there is no portable solution (yet ?)
| 228 | |
| 229 | // XXXX mk: as of C++20, there is no portable solution (yet ?) |
| 230 | std::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 | |
| 253 | nvrhi::GraphicsAPI donut::app::GetGraphicsAPIFromCommandLine(int argc, const char* const* argv) |
| 254 | { |
nothing calls this directly
no outgoing calls
no test coverage detected