summaryrefslogtreecommitdiffstats
path: root/src/android/app
diff options
context:
space:
mode:
authorCharles Lombardo <clombardo169@gmail.com>2023-08-22 21:16:20 +0200
committerCharles Lombardo <clombardo169@gmail.com>2023-08-22 21:16:20 +0200
commit35b77b9599aa437728baf6cf4e2b224db98217fc (patch)
tree2473bddd5d7ad3bb724f2a7d55a687214e413b5b /src/android/app
parentMerge pull request #11302 from vonchenplus/vulkan_macos (diff)
downloadyuzu-35b77b9599aa437728baf6cf4e2b224db98217fc.tar
yuzu-35b77b9599aa437728baf6cf4e2b224db98217fc.tar.gz
yuzu-35b77b9599aa437728baf6cf4e2b224db98217fc.tar.bz2
yuzu-35b77b9599aa437728baf6cf4e2b224db98217fc.tar.lz
yuzu-35b77b9599aa437728baf6cf4e2b224db98217fc.tar.xz
yuzu-35b77b9599aa437728baf6cf4e2b224db98217fc.tar.zst
yuzu-35b77b9599aa437728baf6cf4e2b224db98217fc.zip
Diffstat (limited to 'src/android/app')
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameHelper.kt35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameHelper.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameHelper.kt
index f8e7eeca7..f71d0a098 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameHelper.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameHelper.kt
@@ -11,6 +11,7 @@ import kotlinx.serialization.json.Json
import org.yuzu.yuzu_emu.NativeLibrary
import org.yuzu.yuzu_emu.YuzuApplication
import org.yuzu.yuzu_emu.model.Game
+import org.yuzu.yuzu_emu.model.MinimalDocumentFile
object GameHelper {
const val KEY_GAME_PATH = "game_path"
@@ -29,15 +30,7 @@ object GameHelper {
// Ensure keys are loaded so that ROM metadata can be decrypted.
NativeLibrary.reloadKeys()
- val children = FileUtil.listFiles(context, gamesUri)
- for (file in children) {
- if (!file.isDirectory) {
- // Check that the file has an extension we care about before trying to read out of it.
- if (Game.extensions.contains(FileUtil.getExtension(file.uri))) {
- games.add(getGame(file.uri))
- }
- }
- }
+ addGamesRecursive(games, FileUtil.listFiles(context, gamesUri), 3)
// Cache list of games found on disk
val serializedGames = mutableSetOf<String>()
@@ -52,6 +45,30 @@ object GameHelper {
return games.toList()
}
+ private fun addGamesRecursive(
+ games: MutableList<Game>,
+ files: Array<MinimalDocumentFile>,
+ depth: Int
+ ) {
+ if (depth <= 0) {
+ return
+ }
+
+ files.forEach {
+ if (it.isDirectory) {
+ addGamesRecursive(
+ games,
+ FileUtil.listFiles(YuzuApplication.appContext, it.uri),
+ depth - 1
+ )
+ } else {
+ if (Game.extensions.contains(FileUtil.getExtension(it.uri))) {
+ games.add(getGame(it.uri))
+ }
+ }
+ }
+ }
+
private fun getGame(uri: Uri): Game {
val filePath = uri.toString()
var name = NativeLibrary.getTitle(filePath)