diff options
| author | 2023-06-15 17:20:56 -0700 | |
|---|---|---|
| committer | 2023-06-15 17:20:56 -0700 | |
| commit | 5384fa499869dbf655c6838eb6660138cf80cccc (patch) | |
| tree | 424fc0fdfe89c506cd00607fa920915b58119d2d /src/android | |
| parent | Merge pull request #10639 from 8bitDream/pictureinpicture (diff) | |
| download | yuzu-5384fa499869dbf655c6838eb6660138cf80cccc.tar.gz yuzu-5384fa499869dbf655c6838eb6660138cf80cccc.tar.xz yuzu-5384fa499869dbf655c6838eb6660138cf80cccc.zip | |
android: fs: Fix Exists / IsFile for SAF.
Diffstat (limited to 'src/android')
| -rw-r--r-- | src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt | 18 | ||||
| -rw-r--r-- | src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/DocumentsTree.kt | 5 |
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 | |||
| 19 | import org.yuzu.yuzu_emu.utils.DocumentsTree.Companion.isNativePath | 19 | import org.yuzu.yuzu_emu.utils.DocumentsTree.Companion.isNativePath |
| 20 | import org.yuzu.yuzu_emu.utils.FileUtil.getFileSize | 20 | import org.yuzu.yuzu_emu.utils.FileUtil.getFileSize |
| 21 | import org.yuzu.yuzu_emu.utils.FileUtil.openContentUri | 21 | import org.yuzu.yuzu_emu.utils.FileUtil.openContentUri |
| 22 | import org.yuzu.yuzu_emu.utils.FileUtil.exists | ||
| 23 | import org.yuzu.yuzu_emu.utils.FileUtil.isDirectory | ||
| 22 | import org.yuzu.yuzu_emu.utils.Log.error | 24 | import org.yuzu.yuzu_emu.utils.Log.error |
| 23 | import org.yuzu.yuzu_emu.utils.Log.verbose | 25 | import org.yuzu.yuzu_emu.utils.Log.verbose |
| 24 | import org.yuzu.yuzu_emu.utils.Log.warning | 26 | import 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 |