|
From: Tapio V. <aa...@us...> - 2009-12-11 12:44:59
|
Module: performous
Branch: dance
Commit: e9516b593b2573e392e0b4b6746b6de3901ded65
Author: Vincent Le Ligeour <yo...@us...>
Date: Fri Dec 4 17:34:43 2009 +0100
Added shared data dir outside prefix (gentoo requirement)
---
game/configuration.cc | 6 +++++-
game/fs.cc | 9 +++++++--
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/game/configuration.cc b/game/configuration.cc
index 26d41b6..c40686e 100644
--- a/game/configuration.cc
+++ b/game/configuration.cc
@@ -316,7 +316,11 @@ void readConfig() {
typedef std::vector<std::string> ConfigList;
ConfigList config_list;
char const* root = getenv("PERFORMOUS_ROOT");
- if (root) config_list.push_back(std::string(root) + "/" SHARED_DATA_DIR CONFIG_SCHEMA);
+ if( SHARED_DATA_DIR[0] == '/' ) {
+ config_list.push_back(SHARED_DATA_DIR CONFIG_SCHEMA);
+ } else {
+ if (root) config_list.push_back(std::string(root) + "/" SHARED_DATA_DIR CONFIG_SCHEMA);
+ }
fs::path exec = plugin::execname();
if (!exec.empty()) config_list.push_back(exec.parent_path().string() + "/../" SHARED_DATA_DIR CONFIG_SCHEMA);
ConfigList::const_iterator it = std::find_if(config_list.begin(), config_list.end(), static_cast<bool(&)(fs::path const&)>(fs::exists));
diff --git a/game/fs.cc b/game/fs.cc
index 852529a..3d3fc30 100644
--- a/game/fs.cc
+++ b/game/fs.cc
@@ -88,8 +88,13 @@ std::string getPath(fs::path const& filename) {
dirs.push_back(xdg_data_home ? xdg_data_home / shortDir : getHomeDir() / ".local" / shareDir);
}
#endif
- // Adding relative path from executable
- dirs.push_back(plugin::execname().parent_path().parent_path() / shareDir);
+ if( shareDir.string()[0] == '/' ) {
+ // Adding absolute path
+ dirs.push_back(shareDir);
+ } else {
+ // Adding relative path from executable
+ dirs.push_back(plugin::execname().parent_path().parent_path() / shareDir);
+ }
#ifndef _WIN32
// Adding XDG_DATA_DIRS
{
|