Merge pull request #12153 from JosJuice/android-iso-paths-jni
Android: Use JNI for setting/getting ISO paths
This commit is contained in:
commit
26e9294075
|
@ -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<String?, String?>()
|
||||
|
||||
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"
|
||||
)
|
||||
}
|
||||
}
|
|
@ -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<String> {
|
||||
val dolphinFile = SettingsFile.getSettingsFile(Settings.FILE_DOLPHIN)
|
||||
val dolphinIni = IniFile(dolphinFile)
|
||||
val pathSet = LinkedHashSet<String>()
|
||||
val totalISOPaths =
|
||||
dolphinIni.getInt(Settings.SECTION_INI_GENERAL, SettingsFile.KEY_ISO_PATHS, 0)
|
||||
private fun getFolderPaths(removeNonExistentFolders: Boolean): Array<String> {
|
||||
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<String> {
|
||||
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<String>,
|
||||
recursiveScan: Boolean
|
||||
): Array<String>
|
||||
|
||||
@JvmStatic
|
||||
external fun getIsoPaths(): Array<String>
|
||||
|
||||
@JvmStatic
|
||||
external fun setIsoPaths(paths: Array<String>)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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<jclass>(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<jclass>(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, "<init>", "(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<jclass>(env->NewGlobalRef(linked_hash_map_class));
|
||||
s_linked_hash_map_init = env->GetMethodID(s_linked_hash_map_class, "<init>", "(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);
|
||||
|
|
|
@ -36,12 +36,6 @@ jclass GetHashMapClass();
|
|||
jmethodID GetHashMapInit();
|
||||
jmethodID GetHashMapPut();
|
||||
|
||||
jclass GetIniFileClass();
|
||||
jfieldID GetIniFilePointer();
|
||||
jclass GetIniFileSectionClass();
|
||||
jfieldID GetIniFileSectionPointer();
|
||||
jmethodID GetIniFileSectionConstructor();
|
||||
|
||||
jclass GetCompressCallbackClass();
|
||||
jmethodID GetCompressCallbackRun();
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <jni.h>
|
||||
|
||||
#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)
|
||||
{
|
||||
|
|
|
@ -1,245 +0,0 @@
|
|||
// Copyright 2020 Dolphin Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#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<IniFile::Section*>(
|
||||
env->GetLongField(obj, IDCache::GetIniFileSectionPointer()));
|
||||
}
|
||||
|
||||
static IniFile* GetIniFilePointer(JNIEnv* env, jobject obj)
|
||||
{
|
||||
return reinterpret_cast<IniFile*>(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<jlong>(section));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
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 <typename T>
|
||||
static void SetInSection(JNIEnv* env, jobject obj, jstring key, T new_value)
|
||||
{
|
||||
GetSectionPointer(env, obj)->Set(GetJString(env, key), new_value);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
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 <typename T>
|
||||
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<jboolean>(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<jboolean>(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<jboolean>(GetInSection(env, obj, key, static_cast<bool>(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<bool>(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<jboolean>(
|
||||
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<jboolean>(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<jboolean>(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<jboolean>(
|
||||
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<jboolean>(
|
||||
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<jboolean>(
|
||||
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<jboolean>(Get(env, obj, section_name, key, static_cast<bool>(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<bool>(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<jlong>(new IniFile);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_copyIniFile(JNIEnv* env,
|
||||
jobject,
|
||||
jobject other)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new IniFile(*GetIniFilePointer(env, other)));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue