From 190e71a3188d1ade2a158c8aa0ec737b6929f5a8 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 2 Sep 2023 12:44:26 +0200 Subject: [PATCH] Android: Use JNI for setting/getting ISO paths This gets rid of the last Android-specific code that directly interfaces with INI files. --- .../features/settings/utils/SettingsFile.kt | 107 -------- .../dolphinemu/model/GameFileCache.kt | 94 ++----- .../dolphinemu/dolphinemu/utils/IniFile.java | 118 --------- Source/Android/jni/AndroidCommon/IDCache.cpp | 46 ---- Source/Android/jni/AndroidCommon/IDCache.h | 6 - Source/Android/jni/CMakeLists.txt | 1 - Source/Android/jni/GameList/GameFileCache.cpp | 13 + Source/Android/jni/IniFile.cpp | 245 ------------------ 8 files changed, 35 insertions(+), 595 deletions(-) delete mode 100644 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/utils/SettingsFile.kt delete mode 100644 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/IniFile.java delete mode 100644 Source/Android/jni/IniFile.cpp diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/utils/SettingsFile.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/utils/SettingsFile.kt deleted file mode 100644 index 827f04cbf3..0000000000 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/utils/SettingsFile.kt +++ /dev/null @@ -1,107 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later - -package org.dolphinemu.dolphinemu.features.settings.utils - -import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivityView -import org.dolphinemu.dolphinemu.utils.BiMap -import org.dolphinemu.dolphinemu.utils.DirectoryInitialization -import org.dolphinemu.dolphinemu.utils.IniFile -import org.dolphinemu.dolphinemu.utils.Log -import java.io.File - -/** - * Contains static methods for interacting with .ini files in which settings are stored. - */ -object SettingsFile { - const val KEY_ISO_PATH_BASE = "ISOPath" - const val KEY_ISO_PATHS = "ISOPaths" - private val sectionsMap = BiMap() - - init { - sectionsMap.apply { - add("Hardware", "Video_Hardware") - add("Settings", "Video_Settings") - add("Enhancements", "Video_Enhancements") - add("Stereoscopy", "Video_Stereoscopy") - add("Hacks", "Video_Hacks") - add("GameSpecific", "Video") - } - } - - /** - * Reads a given .ini file from disk and returns it. - * If unsuccessful, outputs an error telling why it failed. - * - * @param file The ini file to load the settings from - * @param ini The object to load into - * @param view The current view. - */ - private fun readFile(file: File, ini: IniFile, view: SettingsActivityView) { - if (!ini.load(file, true)) { - Log.error("[SettingsFile] Error reading from: " + file.absolutePath) - view.onSettingsFileNotFound() - } - } - - fun readFile(fileName: String, ini: IniFile, view: SettingsActivityView) { - readFile(getSettingsFile(fileName), ini, view) - } - - /** - * Reads a given .ini file from disk and returns it. - * If unsuccessful, outputs an error telling why it failed. - * - * @param gameId the id of the game to load settings for. - * @param ini The object to load into - * @param view The current view. - */ - fun readCustomGameSettings( - gameId: String, - ini: IniFile, - view: SettingsActivityView - ) { - readFile(getCustomGameSettingsFile(gameId), ini, view) - } - - /** - * Saves a given .ini file on disk. - * If unsuccessful, outputs an error telling why it failed. - * - * @param fileName The target filename without a path or extension. - * @param ini The IniFile we want to serialize. - * @param view The current view. - */ - fun saveFile(fileName: String, ini: IniFile, view: SettingsActivityView) { - if (!ini.save(getSettingsFile(fileName))) { - Log.error("[SettingsFile] Error saving to: $fileName.ini") - view.showToastMessage("Error saving $fileName.ini") - } - } - - fun saveCustomGameSettings(gameId: String, ini: IniFile) { - ini.save(getCustomGameSettingsFile(gameId)) - } - - fun mapSectionNameFromIni(generalSectionName: String): String? { - return if (sectionsMap.getForward(generalSectionName) != null) { - sectionsMap.getForward(generalSectionName) - } else generalSectionName - } - - fun mapSectionNameToIni(generalSectionName: String): String? { - return if (sectionsMap.getBackward(generalSectionName) != null) { - sectionsMap.getBackward(generalSectionName) - } else generalSectionName - } - - @JvmStatic - fun getSettingsFile(fileName: String): File { - return File(DirectoryInitialization.getUserDirectory() + "/Config/" + fileName + ".ini") - } - - private fun getCustomGameSettingsFile(gameId: String): File { - return File( - DirectoryInitialization.getUserDirectory() + "/GameSettings/" + gameId + ".ini" - ) - } -} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameFileCache.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameFileCache.kt index 74b1bd535a..97064f5521 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameFileCache.kt +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameFileCache.kt @@ -3,12 +3,9 @@ package org.dolphinemu.dolphinemu.model import androidx.annotation.Keep -import org.dolphinemu.dolphinemu.NativeLibrary import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting -import org.dolphinemu.dolphinemu.features.settings.model.Settings -import org.dolphinemu.dolphinemu.features.settings.utils.SettingsFile +import org.dolphinemu.dolphinemu.features.settings.model.NativeConfig import org.dolphinemu.dolphinemu.utils.ContentHandler -import org.dolphinemu.dolphinemu.utils.IniFile import java.io.File class GameFileCache { @@ -57,89 +54,36 @@ class GameFileCache { private external fun newGameFileCache(): Long fun addGameFolder(path: String) { - val dolphinFile = SettingsFile.getSettingsFile(Settings.FILE_DOLPHIN) - val dolphinIni = IniFile(dolphinFile) - val pathSet = getPathSet(false) - val totalISOPaths = - dolphinIni.getInt(Settings.SECTION_INI_GENERAL, SettingsFile.KEY_ISO_PATHS, 0) + val paths = getIsoPaths() - if (!pathSet.contains(path)) { - dolphinIni.setInt( - Settings.SECTION_INI_GENERAL, - SettingsFile.KEY_ISO_PATHS, - totalISOPaths + 1 - ) - dolphinIni.setString( - Settings.SECTION_INI_GENERAL, - SettingsFile.KEY_ISO_PATH_BASE + totalISOPaths, - path - ) - dolphinIni.save(dolphinFile) - NativeLibrary.ReloadConfig() + if (!paths.contains(path)) { + setIsoPaths(paths + path) + NativeConfig.save(NativeConfig.LAYER_BASE) } } - private fun getPathSet(removeNonExistentFolders: Boolean): LinkedHashSet { - val dolphinFile = SettingsFile.getSettingsFile(Settings.FILE_DOLPHIN) - val dolphinIni = IniFile(dolphinFile) - val pathSet = LinkedHashSet() - val totalISOPaths = - dolphinIni.getInt(Settings.SECTION_INI_GENERAL, SettingsFile.KEY_ISO_PATHS, 0) + private fun getFolderPaths(removeNonExistentFolders: Boolean): Array { + val paths = getIsoPaths() - for (i in 0 until totalISOPaths) { - val path = dolphinIni.getString( - Settings.SECTION_INI_GENERAL, - SettingsFile.KEY_ISO_PATH_BASE + i, - "" - ) - - val pathExists = if (ContentHandler.isContentUri(path)) + val filteredPaths = paths.filter {path -> + if (ContentHandler.isContentUri(path)) ContentHandler.exists(path) else File(path).exists() - if (pathExists) { - pathSet.add(path) - } + }.toTypedArray() + + if (removeNonExistentFolders && paths.size > filteredPaths.size) { + setIsoPaths(filteredPaths) + NativeConfig.save(NativeConfig.LAYER_BASE) } - if (removeNonExistentFolders && totalISOPaths > pathSet.size) { - var setIndex = 0 - - dolphinIni.setInt( - Settings.SECTION_INI_GENERAL, - SettingsFile.KEY_ISO_PATHS, - pathSet.size - ) - - // One or more folders have been removed. - for (entry in pathSet) { - dolphinIni.setString( - Settings.SECTION_INI_GENERAL, - SettingsFile.KEY_ISO_PATH_BASE + setIndex, - entry - ) - setIndex++ - } - - // Delete known unnecessary keys. Ignore i values beyond totalISOPaths. - for (i in setIndex until totalISOPaths) { - dolphinIni.deleteKey( - Settings.SECTION_INI_GENERAL, - SettingsFile.KEY_ISO_PATH_BASE + i - ) - } - - dolphinIni.save(dolphinFile) - NativeLibrary.ReloadConfig() - } - return pathSet + return filteredPaths } @JvmStatic fun getAllGamePaths(): Array { val recursiveScan = BooleanSetting.MAIN_RECURSIVE_ISO_PATHS.boolean - val folderPathsSet = getPathSet(true) - val folderPaths = folderPathsSet.toTypedArray() + val folderPaths = getFolderPaths(true) return getAllGamePaths(folderPaths, recursiveScan) } @@ -148,5 +92,11 @@ class GameFileCache { folderPaths: Array, recursiveScan: Boolean ): Array + + @JvmStatic + external fun getIsoPaths(): Array + + @JvmStatic + external fun setIsoPaths(paths: Array) } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/IniFile.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/IniFile.java deleted file mode 100644 index 52aa638382..0000000000 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/IniFile.java +++ /dev/null @@ -1,118 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later - -package org.dolphinemu.dolphinemu.utils; - -import androidx.annotation.Keep; - -import java.io.File; - -// An in-memory copy of an INI file -public class IniFile -{ - // This class is non-static to ensure that the IniFile parent does not get garbage collected - // while a section still is accessible. (The finalizer of IniFile deletes the native sections.) - @SuppressWarnings("InnerClassMayBeStatic") - public class Section - { - @Keep - private long mPointer; - - @Keep - private Section(long pointer) - { - mPointer = pointer; - } - - public native boolean exists(String key); - - public native boolean delete(String key); - - public native String getString(String key, String defaultValue); - - public native boolean getBoolean(String key, boolean defaultValue); - - public native int getInt(String key, int defaultValue); - - public native float getFloat(String key, float defaultValue); - - public native void setString(String key, String newValue); - - public native void setBoolean(String key, boolean newValue); - - public native void setInt(String key, int newValue); - - public native void setFloat(String key, float newFloat); - } - - @Keep - private long mPointer; - - public IniFile() - { - mPointer = newIniFile(); - } - - public IniFile(IniFile other) - { - mPointer = copyIniFile(other); - } - - public IniFile(String path) - { - this(); - load(path, false); - } - - public IniFile(File file) - { - this(); - load(file, false); - } - - public native boolean load(String path, boolean keepCurrentData); - - public boolean load(File file, boolean keepCurrentData) - { - return load(file.getPath(), keepCurrentData); - } - - public native boolean save(String path); - - public boolean save(File file) - { - return save(file.getPath()); - } - - public native Section getOrCreateSection(String sectionName); - - public native boolean exists(String sectionName); - - public native boolean exists(String sectionName, String key); - - public native boolean deleteSection(String sectionName); - - public native boolean deleteKey(String sectionName, String key); - - public native String getString(String sectionName, String key, String defaultValue); - - public native boolean getBoolean(String sectionName, String key, boolean defaultValue); - - public native int getInt(String sectionName, String key, int defaultValue); - - public native float getFloat(String sectionName, String key, float defaultValue); - - public native void setString(String sectionName, String key, String newValue); - - public native void setBoolean(String sectionName, String key, boolean newValue); - - public native void setInt(String sectionName, String key, int newValue); - - public native void setFloat(String sectionName, String key, float newValue); - - @Override - public native void finalize(); - - private native long newIniFile(); - - private native long copyIniFile(IniFile other); -} diff --git a/Source/Android/jni/AndroidCommon/IDCache.cpp b/Source/Android/jni/AndroidCommon/IDCache.cpp index 968d1b7e82..c3bd435af6 100644 --- a/Source/Android/jni/AndroidCommon/IDCache.cpp +++ b/Source/Android/jni/AndroidCommon/IDCache.cpp @@ -36,12 +36,6 @@ static jclass s_hash_map_class; static jmethodID s_hash_map_init; static jmethodID s_hash_map_put; -static jclass s_ini_file_class; -static jfieldID s_ini_file_pointer; -static jclass s_ini_file_section_class; -static jfieldID s_ini_file_section_pointer; -static jmethodID s_ini_file_section_constructor; - static jclass s_compress_cb_class; static jmethodID s_compress_cb_run; @@ -240,31 +234,6 @@ jmethodID GetHashMapPut() return s_hash_map_put; } -jclass GetIniFileClass() -{ - return s_ini_file_class; -} - -jfieldID GetIniFilePointer() -{ - return s_ini_file_pointer; -} - -jclass GetIniFileSectionClass() -{ - return s_ini_file_section_class; -} - -jfieldID GetIniFileSectionPointer() -{ - return s_ini_file_section_pointer; -} - -jmethodID GetIniFileSectionConstructor() -{ - return s_ini_file_section_constructor; -} - jclass GetCompressCallbackClass() { return s_compress_cb_class; @@ -581,19 +550,6 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) "(Ljava/lang/String;)Ljava/lang/String;"); env->DeleteLocalRef(analytics_class); - const jclass ini_file_class = env->FindClass("org/dolphinemu/dolphinemu/utils/IniFile"); - s_ini_file_class = reinterpret_cast(env->NewGlobalRef(ini_file_class)); - s_ini_file_pointer = env->GetFieldID(ini_file_class, "mPointer", "J"); - env->DeleteLocalRef(ini_file_class); - - const jclass ini_file_section_class = - env->FindClass("org/dolphinemu/dolphinemu/utils/IniFile$Section"); - s_ini_file_section_class = reinterpret_cast(env->NewGlobalRef(ini_file_section_class)); - s_ini_file_section_pointer = env->GetFieldID(ini_file_section_class, "mPointer", "J"); - s_ini_file_section_constructor = env->GetMethodID( - ini_file_section_class, "", "(Lorg/dolphinemu/dolphinemu/utils/IniFile;J)V"); - env->DeleteLocalRef(ini_file_section_class); - const jclass linked_hash_map_class = env->FindClass("java/util/LinkedHashMap"); s_linked_hash_map_class = reinterpret_cast(env->NewGlobalRef(linked_hash_map_class)); s_linked_hash_map_init = env->GetMethodID(s_linked_hash_map_class, "", "(I)V"); @@ -768,8 +724,6 @@ JNIEXPORT void JNI_OnUnload(JavaVM* vm, void* reserved) env->DeleteGlobalRef(s_analytics_class); env->DeleteGlobalRef(s_linked_hash_map_class); env->DeleteGlobalRef(s_hash_map_class); - env->DeleteGlobalRef(s_ini_file_class); - env->DeleteGlobalRef(s_ini_file_section_class); env->DeleteGlobalRef(s_compress_cb_class); env->DeleteGlobalRef(s_content_handler_class); env->DeleteGlobalRef(s_network_helper_class); diff --git a/Source/Android/jni/AndroidCommon/IDCache.h b/Source/Android/jni/AndroidCommon/IDCache.h index dc8f4d51a1..eef5a8a085 100644 --- a/Source/Android/jni/AndroidCommon/IDCache.h +++ b/Source/Android/jni/AndroidCommon/IDCache.h @@ -36,12 +36,6 @@ jclass GetHashMapClass(); jmethodID GetHashMapInit(); jmethodID GetHashMapPut(); -jclass GetIniFileClass(); -jfieldID GetIniFilePointer(); -jclass GetIniFileSectionClass(); -jfieldID GetIniFileSectionPointer(); -jmethodID GetIniFileSectionConstructor(); - jclass GetCompressCallbackClass(); jmethodID GetCompressCallbackRun(); diff --git a/Source/Android/jni/CMakeLists.txt b/Source/Android/jni/CMakeLists.txt index bb849074e4..bb18440b02 100644 --- a/Source/Android/jni/CMakeLists.txt +++ b/Source/Android/jni/CMakeLists.txt @@ -27,7 +27,6 @@ add_library(main SHARED Input/MappingCommon.cpp Input/NumericSetting.cpp Input/NumericSetting.h - IniFile.cpp MainAndroid.cpp RiivolutionPatches.cpp SkylanderConfig.cpp diff --git a/Source/Android/jni/GameList/GameFileCache.cpp b/Source/Android/jni/GameList/GameFileCache.cpp index 280de59bf9..27c3b0ef63 100644 --- a/Source/Android/jni/GameList/GameFileCache.cpp +++ b/Source/Android/jni/GameList/GameFileCache.cpp @@ -6,6 +6,7 @@ #include +#include "Core/Config/MainSettings.h" #include "UICommon/GameFileCache.h" #include "jni/AndroidCommon/AndroidCommon.h" #include "jni/AndroidCommon/IDCache.h" @@ -38,6 +39,18 @@ JNIEXPORT jobjectArray JNICALL Java_org_dolphinemu_dolphinemu_model_GameFileCach env, UICommon::FindAllGamePaths(JStringArrayToVector(env, folder_paths), recursive_scan)); } +JNIEXPORT jobjectArray JNICALL +Java_org_dolphinemu_dolphinemu_model_GameFileCache_getIsoPaths(JNIEnv* env, jclass) +{ + return VectorToJStringArray(env, Config::GetIsoPaths()); +} + +JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_model_GameFileCache_setIsoPaths( + JNIEnv* env, jclass, jobjectArray paths) +{ + Config::SetIsoPaths(JStringArrayToVector(env, paths)); +} + JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_model_GameFileCache_getSize(JNIEnv* env, jobject obj) { diff --git a/Source/Android/jni/IniFile.cpp b/Source/Android/jni/IniFile.cpp deleted file mode 100644 index 7172094bdf..0000000000 --- a/Source/Android/jni/IniFile.cpp +++ /dev/null @@ -1,245 +0,0 @@ -// Copyright 2020 Dolphin Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include - -#include "Common/IniFile.h" -#include "jni/AndroidCommon/AndroidCommon.h" -#include "jni/AndroidCommon/IDCache.h" - -using Common::IniFile; - -static IniFile::Section* GetSectionPointer(JNIEnv* env, jobject obj) -{ - return reinterpret_cast( - env->GetLongField(obj, IDCache::GetIniFileSectionPointer())); -} - -static IniFile* GetIniFilePointer(JNIEnv* env, jobject obj) -{ - return reinterpret_cast(env->GetLongField(obj, IDCache::GetIniFilePointer())); -} - -static jobject SectionToJava(JNIEnv* env, jobject ini_file, IniFile::Section* section) -{ - if (!section) - return nullptr; - - return env->NewObject(IDCache::GetIniFileSectionClass(), IDCache::GetIniFileSectionConstructor(), - ini_file, reinterpret_cast(section)); -} - -template -static T GetInSection(JNIEnv* env, jobject obj, jstring key, T default_value) -{ - T result; - GetSectionPointer(env, obj)->Get(GetJString(env, key), &result, default_value); - return result; -} - -template -static void SetInSection(JNIEnv* env, jobject obj, jstring key, T new_value) -{ - GetSectionPointer(env, obj)->Set(GetJString(env, key), new_value); -} - -template -static T Get(JNIEnv* env, jobject obj, jstring section_name, jstring key, T default_value) -{ - T result; - GetIniFilePointer(env, obj) - ->GetOrCreateSection(GetJString(env, section_name)) - ->Get(GetJString(env, key), &result, default_value); - return result; -} - -template -static void Set(JNIEnv* env, jobject obj, jstring section_name, jstring key, T new_value) -{ - GetIniFilePointer(env, obj) - ->GetOrCreateSection(GetJString(env, section_name)) - ->Set(GetJString(env, key), new_value); -} - -extern "C" { - -JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_00024Section_exists( - JNIEnv* env, jobject obj, jstring key) -{ - return static_cast(GetSectionPointer(env, obj)->Exists(GetJString(env, key))); -} - -JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_00024Section_delete( - JNIEnv* env, jobject obj, jstring key) -{ - return static_cast(GetSectionPointer(env, obj)->Delete(GetJString(env, key))); -} - -JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_00024Section_getString( - JNIEnv* env, jobject obj, jstring key, jstring default_value) -{ - return ToJString(env, GetInSection(env, obj, key, GetJString(env, default_value))); -} - -JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_00024Section_getBoolean( - JNIEnv* env, jobject obj, jstring key, jboolean default_value) -{ - return static_cast(GetInSection(env, obj, key, static_cast(default_value))); -} - -JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_00024Section_getInt( - JNIEnv* env, jobject obj, jstring key, jint default_value) -{ - return GetInSection(env, obj, key, default_value); -} - -JNIEXPORT jfloat JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_00024Section_getFloat( - JNIEnv* env, jobject obj, jstring key, jfloat default_value) -{ - return GetInSection(env, obj, key, default_value); -} - -JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_00024Section_setString( - JNIEnv* env, jobject obj, jstring key, jstring new_value) -{ - SetInSection(env, obj, key, GetJString(env, new_value)); -} - -JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_00024Section_setBoolean( - JNIEnv* env, jobject obj, jstring key, jboolean new_value) -{ - SetInSection(env, obj, key, static_cast(new_value)); -} - -JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_00024Section_setInt( - JNIEnv* env, jobject obj, jstring key, jint new_value) -{ - SetInSection(env, obj, key, new_value); -} - -JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_00024Section_setFloat( - JNIEnv* env, jobject obj, jstring key, jfloat new_value) -{ - SetInSection(env, obj, key, new_value); -} - -JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_load( - JNIEnv* env, jobject obj, jstring path, jboolean keep_current_data) -{ - return static_cast( - GetIniFilePointer(env, obj)->Load(GetJString(env, path), keep_current_data)); -} - -JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_save(JNIEnv* env, - jobject obj, - jstring path) -{ - return static_cast(GetIniFilePointer(env, obj)->Save(GetJString(env, path))); -} - -JNIEXPORT jobject JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_getOrCreateSection( - JNIEnv* env, jobject obj, jstring section_name) -{ - return SectionToJava( - env, obj, GetIniFilePointer(env, obj)->GetOrCreateSection(GetJString(env, section_name))); -} - -JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_exists__Ljava_lang_String_2( - JNIEnv* env, jobject obj, jstring section_name) -{ - return static_cast(GetIniFilePointer(env, obj)->Exists(GetJString(env, section_name))); -} - -JNIEXPORT jboolean JNICALL -Java_org_dolphinemu_dolphinemu_utils_IniFile_exists__Ljava_lang_String_2Ljava_lang_String_2( - JNIEnv* env, jobject obj, jstring section_name, jstring key) -{ - return static_cast( - GetIniFilePointer(env, obj)->Exists(GetJString(env, section_name), GetJString(env, key))); -} - -JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_deleteSection( - JNIEnv* env, jobject obj, jstring section_name) -{ - return static_cast( - GetIniFilePointer(env, obj)->DeleteSection(GetJString(env, section_name))); -} - -JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_deleteKey( - JNIEnv* env, jobject obj, jstring section_name, jstring key) -{ - return static_cast( - GetIniFilePointer(env, obj)->DeleteKey(GetJString(env, section_name), GetJString(env, key))); -} - -JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_getString( - JNIEnv* env, jobject obj, jstring section_name, jstring key, jstring default_value) -{ - return ToJString(env, Get(env, obj, section_name, key, GetJString(env, default_value))); -} - -JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_getBoolean( - JNIEnv* env, jobject obj, jstring section_name, jstring key, jboolean default_value) -{ - return static_cast(Get(env, obj, section_name, key, static_cast(default_value))); -} - -JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_getInt(JNIEnv* env, jobject obj, - jstring section_name, - jstring key, - jint default_value) -{ - return Get(env, obj, section_name, key, default_value); -} - -JNIEXPORT jfloat JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_getFloat( - JNIEnv* env, jobject obj, jstring section_name, jstring key, jfloat default_value) -{ - return Get(env, obj, section_name, key, default_value); -} - -JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_setString( - JNIEnv* env, jobject obj, jstring section_name, jstring key, jstring new_value) -{ - Set(env, obj, section_name, key, GetJString(env, new_value)); -} - -JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_setBoolean( - JNIEnv* env, jobject obj, jstring section_name, jstring key, jboolean new_value) -{ - Set(env, obj, section_name, key, static_cast(new_value)); -} - -JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_setInt(JNIEnv* env, jobject obj, - jstring section_name, - jstring key, - jint new_value) -{ - Set(env, obj, section_name, key, new_value); -} - -JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_setFloat( - JNIEnv* env, jobject obj, jstring section_name, jstring key, jfloat new_value) -{ - Set(env, obj, section_name, key, new_value); -} - -JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_finalize(JNIEnv* env, - jobject obj) -{ - delete GetIniFilePointer(env, obj); -} - -JNIEXPORT jlong JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_newIniFile(JNIEnv* env, - jobject) -{ - return reinterpret_cast(new IniFile); -} - -JNIEXPORT jlong JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_copyIniFile(JNIEnv* env, - jobject, - jobject other) -{ - return reinterpret_cast(new IniFile(*GetIniFilePointer(env, other))); -} -}