diff options
Diffstat (limited to 'src/path_utils.cpp')
| -rw-r--r-- | src/path_utils.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/path_utils.cpp b/src/path_utils.cpp index 94bbba5..50c70cd 100644 --- a/src/path_utils.cpp +++ b/src/path_utils.cpp @@ -7,7 +7,7 @@ # include <tchar.h> #endif -std::optional<std::filesystem::path> engine::path_utils::exe_path() noexcept { +std::optional<std::filesystem::path> engine::path_utils::exe() noexcept { #if defined(_WIN32) TCHAR filename[MAX_PATH]; if (!GetModuleFileName(NULL, filename, MAX_PATH)) @@ -21,14 +21,19 @@ std::optional<std::filesystem::path> engine::path_utils::exe_path() noexcept { } engine::path_utils::Paths::Paths() noexcept { - const auto exe_path_opt = engine::path_utils::exe_path(); - if (!exe_path_opt) { + const auto exe_opt = engine::path_utils::exe(); + if (!exe_opt) { std::cerr << "cannot find path of executable" << std::endl; exit(1); } - const auto files_root = (*exe_path_opt).parent_path(); + m_exe = *exe_opt; - 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); + const auto files_root = m_exe.parent_path(); + const auto bin = std::filesystem::weakly_canonical(BINDIR); + const std::filesystem::path pkgdata { PKGDATADIR }; + const auto assets = pkgdata / "assets"; + + m_assets_objs = std::filesystem::canonical(files_root / std::filesystem::weakly_canonical(assets / "objs") .lexically_relative(bin)); + m_assets_textures = std::filesystem::canonical(files_root / std::filesystem::weakly_canonical(assets / "textures").lexically_relative(bin)); + m_spvshaders = std::filesystem::canonical(files_root / std::filesystem::weakly_canonical(SPVSHADERSDIR) .lexically_relative(bin)); } |
