blob: df35ef1656ac152f32d7868ddec1915c775b127e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
}
|