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()); } }