From 523b27e38c0978f6513c95f90582e7e5ab160e3d Mon Sep 17 00:00:00 2001 From: vimene Date: Mon, 16 Feb 2026 11:45:19 +0100 Subject: small improvements --- src/path_utils.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/path_utils.cpp') 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 #endif -std::optional engine::path_utils::exe_path() noexcept { +std::optional engine::path_utils::exe() noexcept { #if defined(_WIN32) TCHAR filename[MAX_PATH]; if (!GetModuleFileName(NULL, filename, MAX_PATH)) @@ -21,14 +21,19 @@ std::optional 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)); } -- cgit v1.2.3