#include "path_utils.hpp" #include #include #include #ifdef _WIN32 # include # include #endif std::optional 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 } engine::path_utils::Paths::Paths() noexcept { const auto exe_path_opt = engine::path_utils::exe_path(); if (!exe_path_opt) { std::cerr << "cannot find path of executable" << std::endl; exit(1); } const auto files_root = (*exe_path_opt).parent_path(); m_assets_objs = files_root / std::filesystem::relative(PKGDATADIR "/assets/objs", BINDIR); m_assets_textures = files_root / std::filesystem::relative(PKGDATADIR "/assets/textures", BINDIR); m_spvshaders = files_root / std::filesystem::relative(SPVSHADERSDIR, BINDIR); }