1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-15 13:51:40 +00:00

Fix issue preventing the Android Editor from displaying the project content

The issue was causing by a bug within the logic for `FileAccessFilesystemJAndroid#eof_reached()` causing that value to remain false after the eof was reached.
This in turn caused an infinite loop in the file scanner preventing the project's content from showing up.

(cherry picked from commit 30479543b0)
This commit is contained in:
Fredia Huya-Kouadio
2022-08-15 00:35:21 -07:00
committed by Rémi Verschelde
parent 7c349574d7
commit a7a8f9c85d
4 changed files with 23 additions and 6 deletions

View File

@@ -104,7 +104,6 @@ internal abstract class DataAccess(private val filePath: String) {
protected abstract val fileChannel: FileChannel
internal var endOfFile = false
private set
fun close() {
try {
@@ -125,9 +124,7 @@ internal abstract class DataAccess(private val filePath: String) {
fun seek(position: Long) {
try {
fileChannel.position(position)
if (position <= size()) {
endOfFile = false
}
endOfFile = position >= fileChannel.size()
} catch (e: Exception) {
Log.w(TAG, "Exception when seeking file $filePath.", e)
}
@@ -161,8 +158,7 @@ internal abstract class DataAccess(private val filePath: String) {
fun read(buffer: ByteBuffer): Int {
return try {
val readBytes = fileChannel.read(buffer)
endOfFile = readBytes == -1
|| (fileChannel.position() >= fileChannel.size() && fileChannel.size() > 0)
endOfFile = readBytes == -1 || (fileChannel.position() >= fileChannel.size())
if (readBytes == -1) {
0
} else {

View File

@@ -194,6 +194,11 @@ class FileAccessHandler(val context: Context) {
return files[fileId].endOfFile
}
fun setFileEof(fileId: Int, eof: Boolean) {
val file = files[fileId] ?: return
file.endOfFile = eof
}
fun fileClose(fileId: Int) {
if (hasFileId(fileId)) {
files[fileId].close()