mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
added games: bind the chosen Games folder into the session at /root/Games, so a folder on an SD card or anywhere else is seen (it was skipped unless it sat inside internal storage, the ROMs folder or the app's own SD library)
This commit is contained in:
1 parent
0e9460bedb
commit
76ba054a84
2 files changed
+19
No files matched your search
@@ -39,8 +39,17 @@ object AddedGames {
|
||||
)
|
||||
|
||||
/** Where a host path appears inside the session, or null when the session cannot see it. */
|
||||
/** Where the chosen Games folder itself is bound inside the session, wherever it is on the device. */
|
||||
const val GUEST_DIR = "/root/Games"
|
||||
|
||||
fun guestPath(context: Context, host: File): String? {
|
||||
val path = host.absolutePath
|
||||
// The Games folder is bound on its own, so a folder anywhere - an SD card, a USB drive -
|
||||
// works without being inside one of the other binds.
|
||||
SessionPrefs.addedGamesDir(context).takeIf { it.isNotEmpty() }?.let { dir ->
|
||||
if (path == dir) return GUEST_DIR
|
||||
if (path.startsWith("$dir/")) return "$GUEST_DIR/" + path.removePrefix("$dir/")
|
||||
}
|
||||
val storage = Environment.getExternalStorageDirectory().absolutePath
|
||||
if (path.startsWith("$storage/")) return "/root/Storage/" + path.removePrefix("$storage/")
|
||||
SessionPrefs.romsDir(context).takeIf { it.isNotEmpty() }?.let { roms ->
|
||||
|
||||
@@ -394,6 +394,16 @@ class SessionService : Service() {
|
||||
} else {
|
||||
Log.i(TAG, "game storage: internal only")
|
||||
}
|
||||
// The user's own games folder (the Steam cog's "Added games"), bound at a fixed place so
|
||||
// the shortcuts the app writes point somewhere whatever storage the folder is on.
|
||||
val games = SessionPrefs.addedGamesDir(this).takeIf { it.isNotEmpty() }?.let { File(it) }
|
||||
if (games != null && games.isDirectory && games.canRead()) {
|
||||
File(home, "Games").mkdirs()
|
||||
binds.add(games.path + ":" + com.steamdeck.launcher.frontend.AddedGames.GUEST_DIR)
|
||||
Log.i(TAG, "added games: $games -> ${com.steamdeck.launcher.frontend.AddedGames.GUEST_DIR}")
|
||||
} else if (games != null) {
|
||||
Log.w(TAG, "added games: $games is not a readable folder this session")
|
||||
}
|
||||
val roms = SessionPrefs.romsDir(this).takeIf { it.isNotEmpty() }?.let { File(it) }
|
||||
if (roms != null && roms.isDirectory && roms.canRead()) {
|
||||
File(home, "ROMs").mkdirs()
|
||||
|
||||
Reference in new issue
Block a user