Merge pull request #115710 from syntaxerror247/fix-seek
Fix `FileAccess.seek_end` behavior on Android
This commit is contained in:
commit
833889aec0
3 changed files with 52 additions and 3 deletions
|
|
@ -203,8 +203,10 @@ internal abstract class DataAccess {
|
|||
abstract fun write(buffer: ByteBuffer): Boolean
|
||||
|
||||
fun seekFromEnd(positionFromEnd: Long) {
|
||||
val positionFromBeginning = max(0, size() - positionFromEnd)
|
||||
seek(positionFromBeginning)
|
||||
val positionFromBeginning = size() + positionFromEnd
|
||||
if (positionFromBeginning >= 0) {
|
||||
seek(positionFromBeginning)
|
||||
}
|
||||
}
|
||||
|
||||
abstract class FileChannelDataAccess(private val filePath: String) : DataAccess() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue