summaryrefslogtreecommitdiff
path: root/src/android/app
diff options
context:
space:
mode:
authorGravatar bunnei2023-06-15 18:39:14 -0700
committerGravatar GitHub2023-06-15 18:39:14 -0700
commit9a04793ae865b7dba009d3133950636eb7ede845 (patch)
tree4fa07212a74c4a7409374e18b1e2442d65f929cd /src/android/app
parentMerge pull request #10790 from liamwhite/arm-driver-moment (diff)
parentandroid: fs: Fix Exists / IsFile for SAF. (diff)
downloadyuzu-9a04793ae865b7dba009d3133950636eb7ede845.tar.gz
yuzu-9a04793ae865b7dba009d3133950636eb7ede845.tar.xz
yuzu-9a04793ae865b7dba009d3133950636eb7ede845.zip
Merge pull request #10796 from bunnei/fix-saf
android: fs: Fix Exists / IsFile for SAF.
Diffstat (limited to 'src/android/app')
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt18
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/DocumentsTree.kt5
2 files changed, 23 insertions, 0 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 22f0a2646..f3bfbe7eb 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
@@ -19,6 +19,8 @@ import org.yuzu.yuzu_emu.activities.EmulationActivity
19import org.yuzu.yuzu_emu.utils.DocumentsTree.Companion.isNativePath 19import org.yuzu.yuzu_emu.utils.DocumentsTree.Companion.isNativePath
20import org.yuzu.yuzu_emu.utils.FileUtil.getFileSize 20import org.yuzu.yuzu_emu.utils.FileUtil.getFileSize
21import org.yuzu.yuzu_emu.utils.FileUtil.openContentUri 21import org.yuzu.yuzu_emu.utils.FileUtil.openContentUri
22import org.yuzu.yuzu_emu.utils.FileUtil.exists
23import org.yuzu.yuzu_emu.utils.FileUtil.isDirectory
22import org.yuzu.yuzu_emu.utils.Log.error 24import org.yuzu.yuzu_emu.utils.Log.error
23import org.yuzu.yuzu_emu.utils.Log.verbose 25import org.yuzu.yuzu_emu.utils.Log.verbose
24import org.yuzu.yuzu_emu.utils.Log.warning 26import org.yuzu.yuzu_emu.utils.Log.warning
@@ -85,6 +87,22 @@ object NativeLibrary {
85 } else getFileSize(appContext, path) 87 } else getFileSize(appContext, path)
86 } 88 }
87 89
90 @Keep
91 @JvmStatic
92 fun exists(path: String?): Boolean {
93 return if (isNativePath(path!!)) {
94 YuzuApplication.documentsTree!!.exists(path)
95 } else exists(appContext, path)
96 }
97
98 @Keep
99 @JvmStatic
100 fun isDirectory(path: String?): Boolean {
101 return if (isNativePath(path!!)) {
102 YuzuApplication.documentsTree!!.isDirectory(path)
103 } else isDirectory(appContext, path)
104 }
105
88 /** 106 /**
89 * Returns true if pro controller isn't available and handheld is 107 * Returns true if pro controller isn't available and handheld is
90 */ 108 */
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 cc8ea6b9d..f8abae445 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
@@ -36,6 +36,11 @@ class DocumentsTree {
36 return resolvePath(filepath) != null 36 return resolvePath(filepath) != null
37 } 37 }
38 38
39 fun isDirectory(filepath: String): Boolean {
40 val node = resolvePath(filepath)
41 return node != null && node.isDirectory
42 }
43
39 private fun resolvePath(filepath: String): DocumentsNode? { 44 private fun resolvePath(filepath: String): DocumentsNode? {
40 val tokens = StringTokenizer(filepath, File.separator, false) 45 val tokens = StringTokenizer(filepath, File.separator, false)
41 var iterator = root 46 var iterator = root