Add a fallback lib path for server creation

This commit is contained in:
Deve 2018-09-28 23:15:16 +02:00
parent e5a66cf5af
commit 51c67aa1e4
3 changed files with 44 additions and 2 deletions

View File

@ -631,3 +631,26 @@ std::string AssetsAndroid::getDataPath()
return "";
}
//-----------------------------------------------------------------------------
/** Get a path for internal lib directory
* \return Path for internal lib directory or empty string when failed
*/
std::string AssetsAndroid::getLibPath()
{
#ifdef ANDROID
AndroidApplicationInfo application_info =
CIrrDeviceAndroid::getApplicationInfo(global_android_app->activity);
std::string lib_path = application_info.native_lib_dir;
if (access(lib_path.c_str(), R_OK) != 0)
{
lib_path = "";
}
return lib_path;
#endif
return "";
}

View File

@ -43,6 +43,7 @@ public:
void init();
static std::string getDataPath();
static std::string getLibPath();
};

View File

@ -283,9 +283,27 @@ bool SeparateProcess::createChildProcess(const std::string& exe,
}
std::string data_path = AssetsAndroid::getDataPath();
std::string main_path = data_path + "/lib/libmain.so";
std::string main_path;
if (data_path.empty() || access(main_path.c_str(), R_OK) != 0)
if (!data_path.empty())
{
main_path = data_path + "/lib/libmain.so";
}
if (main_path.empty() || access(main_path.c_str(), R_OK) != 0)
{
std::string lib_path = AssetsAndroid::getLibPath();
if (!lib_path.empty())
{
main_path = lib_path + "/libmain.so";
}
Log::info("SeparateProcess", "Trying to use fallback lib path: %s",
main_path.c_str());
}
if (main_path.empty() || access(main_path.c_str(), R_OK) != 0)
{
Log::error("SeparateProcess", "Error: Cannot read libmain.so");
return false;