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