You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
[FileAccess] Return error codes from store_* methods.
This commit is contained in:
committed by
Pāvels Nadtočajevs
parent
56a7dba10b
commit
a4b17e7852
@@ -145,7 +145,8 @@ internal class AssetData(context: Context, private val filePath: String, accessF
|
||||
}
|
||||
}
|
||||
|
||||
override fun write(buffer: ByteBuffer) {
|
||||
override fun write(buffer: ByteBuffer): Boolean {
|
||||
Log.w(TAG, "write() is not supported.")
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ internal abstract class DataAccess {
|
||||
abstract fun position(): Long
|
||||
abstract fun size(): Long
|
||||
abstract fun read(buffer: ByteBuffer): Int
|
||||
abstract fun write(buffer: ByteBuffer)
|
||||
abstract fun write(buffer: ByteBuffer): Boolean
|
||||
|
||||
fun seekFromEnd(positionFromEnd: Long) {
|
||||
val positionFromBeginning = max(0, size() - positionFromEnd)
|
||||
@@ -254,14 +254,16 @@ internal abstract class DataAccess {
|
||||
}
|
||||
}
|
||||
|
||||
override fun write(buffer: ByteBuffer) {
|
||||
override fun write(buffer: ByteBuffer): Boolean {
|
||||
try {
|
||||
val writtenBytes = fileChannel.write(buffer)
|
||||
if (writtenBytes > 0) {
|
||||
endOfFile = false
|
||||
}
|
||||
return true
|
||||
} catch (e: IOException) {
|
||||
Log.w(TAG, "Exception while writing to file $filePath.", e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,12 +191,12 @@ class FileAccessHandler(val context: Context) {
|
||||
return files[fileId].read(byteBuffer)
|
||||
}
|
||||
|
||||
fun fileWrite(fileId: Int, byteBuffer: ByteBuffer?) {
|
||||
fun fileWrite(fileId: Int, byteBuffer: ByteBuffer?): Boolean {
|
||||
if (!hasFileId(fileId) || byteBuffer == null) {
|
||||
return
|
||||
return false
|
||||
}
|
||||
|
||||
files[fileId].write(byteBuffer)
|
||||
return files[fileId].write(byteBuffer)
|
||||
}
|
||||
|
||||
fun fileFlush(fileId: Int) {
|
||||
|
||||
Reference in New Issue
Block a user