From 0743cce8456a4f12de36976d1e103c91f5b4d227 Mon Sep 17 00:00:00 2001 From: bailwillharr Date: Sat, 3 Sep 2022 17:13:38 +0100 Subject: [PATCH] Fix bug with determining the location of "res/" --- src/resource_manager.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/resource_manager.cpp b/src/resource_manager.cpp index 34941e1..6a2da36 100644 --- a/src/resource_manager.cpp +++ b/src/resource_manager.cpp @@ -2,21 +2,25 @@ #ifdef _MSC_VER #include +#include #define MAX_PATH 260 #endif +#include "log.hpp" + ResourceManager::ResourceManager() { #ifdef _MSC_VER CHAR exeDirBuf[MAX_PATH + 1]; GetModuleFileNameA(NULL, exeDirBuf, MAX_PATH + 1); std::filesystem::path cwd = std::filesystem::path(exeDirBuf).parent_path(); + (void)_chdir((const char*)std::filesystem::absolute(cwd).c_str()); #else std::filesystem::path cwd = std::filesystem::current_path(); #endif if (std::filesystem::is_directory(cwd / "res")) { - m_resourcesPath = std::filesystem::absolute("res"); + m_resourcesPath = cwd / "res"; } else { m_resourcesPath = cwd.parent_path() / "share" / "sdltest"; } @@ -26,7 +30,7 @@ ResourceManager::ResourceManager() } if (std::filesystem::is_directory(m_resourcesPath) == false) { - throw std::runtime_error("Unable to determine resources location"); + throw std::runtime_error("Unable to determine resources location. CWD: " + cwd.string()); } }