diff options
Diffstat (limited to 'src/path_utils.cpp')
| -rw-r--r-- | src/path_utils.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/path_utils.cpp b/src/path_utils.cpp new file mode 100644 index 0000000..df35ef1 --- /dev/null +++ b/src/path_utils.cpp @@ -0,0 +1,20 @@ +#include "path_utils.hpp" +#include <optional> +#include <filesystem> +#ifdef _WIN32 +# include <windows.h> +# include <tchar.h> +#endif + +std::optional<std::filesystem::path> engine::path_utils::exe_path() noexcept { +#if defined(_WIN32) + TCHAR filename[MAX_PATH]; + if (!GetModuleFileName(NULL, filename, MAX_PATH)) + return {}; + return std::filesystem::path(filename); +#elif defined(linux) + return std::filesystem::canonical("/proc/self/exe"); +#else +# error "operating system not supported" +#endif +} |
