Skip to content

Commit

Permalink
Look for data files in the folder where the executable is
Browse files Browse the repository at this point in the history
Kind of fix or workaround for #7
  • Loading branch information
sandsmark committed Jan 23, 2021
1 parent 3db7187 commit a66eca9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/core/Utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,9 @@ void throwException__(const std::string &message)
{
throw std::logic_error(message);
}

std::string util::executableDirectory()
{
std::filesystem::path filePath = executablePath();
return filePath.parent_path().string();
}
1 change: 1 addition & 0 deletions src/core/Utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ inline bool floatsEquals(const double a, const double b)
bool openUrl(const std::string &url, std::string *error);

std::string executablePath();
std::string executableDirectory();

}

4 changes: 4 additions & 0 deletions src/global/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,10 @@ bool Config::parseOptions(int argc, char **argv)
}
}

if (getValue(GamePath).empty()) {
setValue(GamePath, util::executableDirectory());
}

if (getValue(GamePath).empty()) {
setValue(GamePath, getRegistryString(s_registryGroupTC, s_registryKey));
}
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ try
break;
}
}
DBG << "executable path" << util::executablePath();
DBG << "executable path" << util::executablePath() << "folder:" << util::executableDirectory();

Config &config = Config::Inst();

Expand Down

0 comments on commit a66eca9

Please sign in to comment.