use jni basedirectory for android paths

This commit is contained in:
qimiko 2024-01-08 16:21:56 -07:00
parent 198948319b
commit 91c68f525b
No known key found for this signature in database
GPG key ID: D2D404DD810FE0E3

View file

@ -44,20 +44,28 @@ CCPoint cocos::getMousePos() {
return CCPoint(0, 0);
}
namespace {
ghc::filesystem::path getBaseDir() {
JniMethodInfo t;
std::string path = "/storage/emulated/0/Android/data/com.geode.launcher/files";
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));
t.env->DeleteLocalRef(t.classID);
path = JniHelper::jstring2string(str);
t.env->DeleteLocalRef(str);
}
return ghc::filesystem::path(path);
}
}
ghc::filesystem::path dirs::getGameDir() {
return ghc::filesystem::path(
"/storage/emulated/0/Android/data/com.geode.launcher/files/game"
// "/data/user/0/com.geode.launcher/files/"
/*CCFileUtils::sharedFileUtils()->getWritablePath().c_str()*/
);
return getBaseDir() / "game";
}
ghc::filesystem::path dirs::getSaveDir() {
return ghc::filesystem::path(
"/storage/emulated/0/Android/data/com.geode.launcher/files/save"
// "/data/user/0/com.geode.launcher/files/"
/*CCFileUtils::sharedFileUtils()->getWritablePath().c_str()*/
);
return getBaseDir() / "save";
}
ghc::filesystem::path dirs::getModRuntimeDir() {