mirror of
https://github.com/bailwillharr/engine.git
synced 2024-09-21 04:51:18 +00:00
Fix bug with determining the location of "res/"
This commit is contained in:
parent
f0433f145c
commit
0743cce845
@ -2,21 +2,25 @@
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <windows.h>
|
||||
#include <direct.h>
|
||||
#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());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user