forked from MeloNX/MeloNX
use file descriptors to load game list
This commit is contained in:
parent
4805d1f51a
commit
1659cc5294
@ -1,11 +1,9 @@
|
||||
package org.ryujinx.android.viewmodels
|
||||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.os.ParcelFileDescriptor
|
||||
import androidx.documentfile.provider.DocumentFile
|
||||
import com.anggrayudi.storage.file.extension
|
||||
import org.ryujinx.android.Helpers
|
||||
import org.ryujinx.android.RyujinxNative
|
||||
|
||||
|
||||
@ -21,8 +19,9 @@ class GameModel(var file: DocumentFile, val context: Context) {
|
||||
|
||||
init {
|
||||
fileName = file.name
|
||||
val absPath = getPath()
|
||||
val gameInfo = RyujinxNative().deviceGetGameInfoFromPath(absPath ?: "")
|
||||
var pid = open()
|
||||
val gameInfo = RyujinxNative().deviceGetGameInfo(pid, file.extension.contains("xci"))
|
||||
close()
|
||||
|
||||
fileSize = gameInfo.FileSize
|
||||
titleId = gameInfo.TitleId
|
||||
@ -32,13 +31,6 @@ class GameModel(var file: DocumentFile, val context: Context) {
|
||||
iconCache = gameInfo.IconCache
|
||||
}
|
||||
|
||||
fun getPath() : String? {
|
||||
var uri = file.uri
|
||||
if (uri.scheme != "file")
|
||||
uri = Uri.parse("file://" + Helpers.getPath(context, file.uri))
|
||||
return uri.path
|
||||
}
|
||||
|
||||
fun open() : Int {
|
||||
descriptor = context.contentResolver.openFileDescriptor(file.uri, "rw")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user