summaryrefslogtreecommitdiffstats
path: root/src/android/app
diff options
context:
space:
mode:
authorCharles Lombardo <clombardo169@gmail.com>2023-10-25 04:51:09 +0200
committerCharles Lombardo <clombardo169@gmail.com>2023-10-30 16:38:10 +0100
commit585b6e9d46b207a6b48a021ea35636fb8c92b405 (patch)
tree8909909ba82a90979748d6fa2bd875aa47cea050 /src/android/app
parentandroid: Refactor game metadata collection to new file (diff)
downloadyuzu-585b6e9d46b207a6b48a021ea35636fb8c92b405.tar
yuzu-585b6e9d46b207a6b48a021ea35636fb8c92b405.tar.gz
yuzu-585b6e9d46b207a6b48a021ea35636fb8c92b405.tar.bz2
yuzu-585b6e9d46b207a6b48a021ea35636fb8c92b405.tar.lz
yuzu-585b6e9d46b207a6b48a021ea35636fb8c92b405.tar.xz
yuzu-585b6e9d46b207a6b48a021ea35636fb8c92b405.tar.zst
yuzu-585b6e9d46b207a6b48a021ea35636fb8c92b405.zip
Diffstat (limited to 'src/android/app')
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt29
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/DocumentsTree.kt17
-rw-r--r--src/android/app/src/main/jni/native.h8
3 files changed, 45 insertions, 9 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt
index 22c9b05de..5fe235dba 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt
@@ -5,6 +5,7 @@ package org.yuzu.yuzu_emu
import android.app.Dialog
import android.content.DialogInterface
+import android.net.Uri
import android.os.Bundle
import android.text.Html
import android.text.method.LinkMovementMethod
@@ -16,7 +17,7 @@ import androidx.fragment.app.DialogFragment
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import java.lang.ref.WeakReference
import org.yuzu.yuzu_emu.activities.EmulationActivity
-import org.yuzu.yuzu_emu.utils.DocumentsTree.Companion.isNativePath
+import org.yuzu.yuzu_emu.utils.DocumentsTree
import org.yuzu.yuzu_emu.utils.FileUtil
import org.yuzu.yuzu_emu.utils.Log
import org.yuzu.yuzu_emu.utils.SerializableHelper.serializable
@@ -68,7 +69,7 @@ object NativeLibrary {
@Keep
@JvmStatic
fun openContentUri(path: String?, openmode: String?): Int {
- return if (isNativePath(path!!)) {
+ return if (DocumentsTree.isNativePath(path!!)) {
YuzuApplication.documentsTree!!.openContentUri(path, openmode)
} else {
FileUtil.openContentUri(path, openmode)
@@ -78,7 +79,7 @@ object NativeLibrary {
@Keep
@JvmStatic
fun getSize(path: String?): Long {
- return if (isNativePath(path!!)) {
+ return if (DocumentsTree.isNativePath(path!!)) {
YuzuApplication.documentsTree!!.getFileSize(path)
} else {
FileUtil.getFileSize(path)
@@ -88,7 +89,7 @@ object NativeLibrary {
@Keep
@JvmStatic
fun exists(path: String?): Boolean {
- return if (isNativePath(path!!)) {
+ return if (DocumentsTree.isNativePath(path!!)) {
YuzuApplication.documentsTree!!.exists(path)
} else {
FileUtil.exists(path)
@@ -98,13 +99,31 @@ object NativeLibrary {
@Keep
@JvmStatic
fun isDirectory(path: String?): Boolean {
- return if (isNativePath(path!!)) {
+ return if (DocumentsTree.isNativePath(path!!)) {
YuzuApplication.documentsTree!!.isDirectory(path)
} else {
FileUtil.isDirectory(path)
}
}
+ @Keep
+ @JvmStatic
+ fun getParentDirectory(path: String): String =
+ if (DocumentsTree.isNativePath(path)) {
+ YuzuApplication.documentsTree!!.getParentDirectory(path)
+ } else {
+ path
+ }
+
+ @Keep
+ @JvmStatic
+ fun getFilename(path: String): String =
+ if (DocumentsTree.isNativePath(path)) {
+ YuzuApplication.documentsTree!!.getFilename(path)
+ } else {
+ FileUtil.getFilename(Uri.parse(path))
+ }
+
/**
* Returns true if pro controller isn't available and handheld is
*/
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/DocumentsTree.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/DocumentsTree.kt
index eafcf9e42..738275297 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/DocumentsTree.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/DocumentsTree.kt
@@ -42,6 +42,23 @@ class DocumentsTree {
return node != null && node.isDirectory
}
+ fun getParentDirectory(filepath: String): String {
+ val node = resolvePath(filepath)!!
+ val parentNode = node.parent
+ if (parentNode != null && parentNode.isDirectory) {
+ return parentNode.uri!!.toString()
+ }
+ return node.uri!!.toString()
+ }
+
+ fun getFilename(filepath: String): String {
+ val node = resolvePath(filepath)
+ if (node != null) {
+ return node.name!!
+ }
+ return filepath
+ }
+
private fun resolvePath(filepath: String): DocumentsNode? {
val tokens = StringTokenizer(filepath, File.separator, false)
var iterator = root
diff --git a/src/android/app/src/main/jni/native.h b/src/android/app/src/main/jni/native.h
index 2eb5c4349..b1db87e41 100644
--- a/src/android/app/src/main/jni/native.h
+++ b/src/android/app/src/main/jni/native.h
@@ -2,14 +2,14 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include <android/native_window_jni.h>
+#include "common/detached_tasks.h"
#include "core/core.h"
+#include "core/file_sys/registered_cache.h"
+#include "core/hle/service/acc/profile_manager.h"
#include "core/perf_stats.h"
-#include "jni/emu_window/emu_window.h"
#include "jni/applets/software_keyboard.h"
+#include "jni/emu_window/emu_window.h"
#include "video_core/rasterizer_interface.h"
-#include "common/detached_tasks.h"
-#include "core/hle/service/acc/profile_manager.h"
-#include "core/file_sys/registered_cache.h"
#pragma once