From 748b2dc257650d9ff6e740496802cb977227bc21 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 1 Nov 2013 13:27:00 +0300 Subject: move package directory variable from client into paths. --- src/client.cpp | 3 +-- src/client.h | 4 ---- src/resources/resourcemanager.cpp | 4 ++-- src/utils/paths.cpp | 15 +++++++++++++++ src/utils/paths.h | 4 ++++ 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/client.cpp b/src/client.cpp index dd5b06776..130ddcc80 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -278,7 +278,6 @@ class LoginListener final : public gcn::ActionListener Client::Client(const Options &options) : gcn::ActionListener(), mOptions(options), - mPackageDir(), mConfigDir(), mServerConfigDir(), mLocalDataDir(), @@ -548,7 +547,7 @@ void Client::gameInit() // mPackageDir = path; #endif resman->addToSearchPath(PKG_DATADIR "data", false); - mPackageDir = PKG_DATADIR "data"; + setPackageDir(PKG_DATADIR "data"); resman->addToSearchPath("data", false); #ifdef ANDROID diff --git a/src/client.h b/src/client.h index 48801b274..9d1a23266 100644 --- a/src/client.h +++ b/src/client.h @@ -233,9 +233,6 @@ public: State getState() const A_WARN_UNUSED { return mState; } - const std::string &getPackageDirectory() const A_WARN_UNUSED - { return mPackageDir; } - const std::string &getConfigDirectory() const A_WARN_UNUSED { return mConfigDir; } @@ -390,7 +387,6 @@ private: Options mOptions; - std::string mPackageDir; std::string mConfigDir; std::string mServerConfigDir; std::string mLocalDataDir; diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index 5cdb22e96..d50df6b50 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -39,6 +39,7 @@ #include "resources/spritedef.h" #include "utils/mkdir.h" +#include "utils/paths.h" #include "utils/physfscheckutils.h" #include "utils/physfsrwops.h" #include "utils/sdlcheckutils.h" @@ -427,8 +428,7 @@ std::string ResourceManager::getPath(const std::string &file) const else { // if not found in search path return the default path - path = std::string(client->getPackageDirectory()).append( - dirSeparator).append(file); + path = getPackageDir().append(dirSeparator).append(file); } return path; diff --git a/src/utils/paths.cpp b/src/utils/paths.cpp index dbe0cccce..cba263027 100644 --- a/src/utils/paths.cpp +++ b/src/utils/paths.cpp @@ -52,6 +52,11 @@ #include "debug.h" +namespace +{ + std::string mPackageDir; +} // namespace + std::string getRealPath(const std::string &str) { #if defined(__OpenBSD__) || defined(__ANDROID__) || defined(__native_client__) @@ -193,3 +198,13 @@ std::string getSdStoragePath() return getenv("DATADIR2"); } #endif + +std::string getPackageDir() +{ + return mPackageDir; +} + +void setPackageDir(const std::string &dir) +{ + mPackageDir = dir; +} diff --git a/src/utils/paths.h b/src/utils/paths.h index 6e2d17808..cb0af64ad 100644 --- a/src/utils/paths.h +++ b/src/utils/paths.h @@ -43,4 +43,8 @@ std::string getDesktopDir() A_WARN_UNUSED; std::string getSdStoragePath() A_WARN_UNUSED; #endif +std::string getPackageDir() A_WARN_UNUSED; + +void setPackageDir(const std::string &dir); + #endif // UTILS_PATHS_H -- cgit v1.2.3-70-g09d2