Unix: prioritize local resource directory over installed one.

pull/33/head
whitequark 2016-07-19 09:31:58 +00:00
parent cbf84a9d2b
commit 33e292a6bc
1 changed files with 6 additions and 4 deletions

View File

@ -1536,11 +1536,13 @@ const void *LoadResource(const std::string &name, size_t *size) {
struct stat st; struct stat st;
std::string path; std::string path;
path = (UNIX_DATADIR "/") + name; if(resource_dir.empty()) {
if(stat(path.c_str(), &st)) { path = (UNIX_DATADIR "/") + name;
ssassert(errno == ENOENT, "Unexpected stat() error"); } else {
ssassert(!resource_dir.empty(), "Expected local resource directory to be set");
path = resource_dir + "/" + name; path = resource_dir + "/" + name;
}
if(stat(path.c_str(), &st)) {
ssassert(!stat(path.c_str(), &st), "Cannot find resource"); ssassert(!stat(path.c_str(), &st), "Cannot find resource");
} }