From 7f2484d82112851dbeba83afd18790a58b03599d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 29 Oct 2013 23:36:53 +0300 Subject: Initial porting to NACL by Vasily_Makarov. --- src/utils/paths.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/utils/paths.cpp') diff --git a/src/utils/paths.cpp b/src/utils/paths.cpp index e3992cd72..dbe0cccce 100644 --- a/src/utils/paths.cpp +++ b/src/utils/paths.cpp @@ -30,11 +30,18 @@ #include "resources/resourcemanager.h" +#ifdef __native_client__ +#include +#define realpath(N, R) strcpy(R, N) +#endif + #ifdef WIN32 #include "utils/specialfolder.h" #define realpath(N, R) _fullpath((R), (N), _MAX_PATH) #elif defined __OpenBSD__ #include +#elif defined __native_client__ +#include #endif #ifdef ANDROID @@ -47,7 +54,7 @@ std::string getRealPath(const std::string &str) { -#if defined(__OpenBSD__) || defined(__ANDROID__) +#if defined(__OpenBSD__) || defined(__ANDROID__) || defined(__native_client__) char *realPath = reinterpret_cast(calloc(PATH_MAX, sizeof(char))); realpath(str.c_str(), realPath); #else -- cgit v1.2.3-70-g09d2 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(-) (limited to 'src/utils/paths.cpp') 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 From ad4421c3f53b7d4b69bd8560029782295f36c4af Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 2 Nov 2013 14:25:05 +0300 Subject: add missing check. --- src/input/inputmanager.cpp | 2 ++ src/utils/paths.cpp | 2 ++ 2 files changed, 4 insertions(+) (limited to 'src/utils/paths.cpp') diff --git a/src/input/inputmanager.cpp b/src/input/inputmanager.cpp index 7e7da4433..c84044771 100644 --- a/src/input/inputmanager.cpp +++ b/src/input/inputmanager.cpp @@ -29,7 +29,9 @@ #include "input/joystick.h" #include "input/keyboardconfig.h" #include "input/keyboarddata.h" +#ifdef USE_SDL2 #include "input/multitouchmanager.h" +#endif #include "gui/gui.h" #include "gui/sdlinput.h" diff --git a/src/utils/paths.cpp b/src/utils/paths.cpp index cba263027..e1a4ee03c 100644 --- a/src/utils/paths.cpp +++ b/src/utils/paths.cpp @@ -61,6 +61,8 @@ std::string getRealPath(const std::string &str) { #if defined(__OpenBSD__) || defined(__ANDROID__) || defined(__native_client__) char *realPath = reinterpret_cast(calloc(PATH_MAX, sizeof(char))); + if (!realPath) + return ""; realpath(str.c_str(), realPath); #else char *realPath = realpath(str.c_str(), nullptr); -- cgit v1.2.3-70-g09d2