Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Suyu
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
many-archive
Suyu
Commits
35b77b95
There was an error fetching the commit references. Please try again later.
Commit
35b77b95
authored
1 year ago
by
Charles Lombardo
Browse files
Options
Downloads
Patches
Plain Diff
android: Search game directory recursively
parent
bc4ad5e6
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameHelper.kt
+26
-9
26 additions, 9 deletions
...d/app/src/main/java/org/yuzu/yuzu_emu/utils/GameHelper.kt
with
26 additions
and
9 deletions
src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameHelper.kt
+
26
−
9
View file @
35b77b95
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment