io: rework how we set SDL_IOStream status.

This now relies on the implementation to set these flags on short reads/writes
instead of the higher level checking if SDL_SetError() was called.

Additionally (and crucially), this now sets ERROR or EOF on all short reads,
across all backends, not just when we get a zero-byte return value.

Fixes #13720.
This commit is contained in:
Ryan C. Gordon
2025-09-05 10:12:42 -04:00
parent 129c97f610
commit b8197a2291
3 changed files with 66 additions and 41 deletions

View File

@@ -1827,7 +1827,10 @@ size_t Android_JNI_FileRead(void *userdata, void *buffer, size_t size, SDL_IOSta
const int bytes = AAsset_read((AAsset *)userdata, buffer, size);
if (bytes < 0) {
SDL_SetError("AAsset_read() failed");
*status = SDL_IO_STATUS_ERROR;
return 0;
} else if (bytes < size) {
*status = SDL_IO_STATUS_EOF;
}
return (size_t)bytes;
}
@@ -1835,6 +1838,7 @@ size_t Android_JNI_FileRead(void *userdata, void *buffer, size_t size, SDL_IOSta
size_t Android_JNI_FileWrite(void *userdata, const void *buffer, size_t size, SDL_IOStatus *status)
{
SDL_SetError("Cannot write to Android package filesystem");
*status = SDL_IO_STATUS_ERROR;
return 0;
}