mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-27 01:45:35 -05:00
workaround multithreaded base directory issues
This commit is contained in:
parent
aecd7cc186
commit
6b1164d4a6
1 changed files with 9 additions and 1 deletions
|
@ -56,10 +56,17 @@ namespace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// jni breaks over multithreading, so the value is stored to avoid more jni calls
|
||||||
|
std::string s_savedBaseDir = "";
|
||||||
|
|
||||||
ghc::filesystem::path getBaseDir() {
|
ghc::filesystem::path getBaseDir() {
|
||||||
JniMethodInfo t;
|
|
||||||
std::string path = "/storage/emulated/0/Android/data/com.geode.launcher/files";
|
std::string path = "/storage/emulated/0/Android/data/com.geode.launcher/files";
|
||||||
|
|
||||||
|
if (!s_savedBaseDir.empty()) {
|
||||||
|
return ghc::filesystem::path(s_savedBaseDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
JniMethodInfo t;
|
||||||
if (JniHelper::getStaticMethodInfo(t, "com/geode/launcher/utils/GeodeUtils", "getBaseDirectory", "()Ljava/lang/String;")) {
|
if (JniHelper::getStaticMethodInfo(t, "com/geode/launcher/utils/GeodeUtils", "getBaseDirectory", "()Ljava/lang/String;")) {
|
||||||
jstring str = reinterpret_cast<jstring>(t.env->CallStaticObjectMethod(t.classID, t.methodID));
|
jstring str = reinterpret_cast<jstring>(t.env->CallStaticObjectMethod(t.classID, t.methodID));
|
||||||
t.env->DeleteLocalRef(t.classID);
|
t.env->DeleteLocalRef(t.classID);
|
||||||
|
@ -69,6 +76,7 @@ namespace {
|
||||||
clearJNIException();
|
clearJNIException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s_savedBaseDir = path;
|
||||||
return ghc::filesystem::path(path);
|
return ghc::filesystem::path(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue