SDL_rwops read/write functions return size_t again

The current status is stored in the SDL_rwops 'status' field to be able to determine whether a 0 return value is caused by end of file, an error, or a non-blocking source not being ready.

The functions to read sized datatypes now return SDL_bool so you can detect read errors.

Fixes https://github.com/libsdl-org/SDL/issues/6729
This commit is contained in:
Sam Lantinga 2023-08-06 13:51:03 -07:00
parent c03f5b4b69
commit b903ccf945
20 changed files with 1154 additions and 754 deletions

View file

@ -1983,13 +1983,18 @@ int Android_JNI_FileOpen(SDL_RWops *ctx,
return 0;
}
Sint64 Android_JNI_FileRead(SDL_RWops *ctx, void *buffer, Sint64 size)
size_t Android_JNI_FileRead(SDL_RWops *ctx, void *buffer, size_t size)
{
AAsset *asset = (AAsset *)ctx->hidden.androidio.asset;
return (Sint64) AAsset_read(asset, buffer, (size_t) size);
int bytes = AAsset_read(asset, buffer, size);
if (bytes < 0) {
SDL_SetError("AAsset_read() failed");
return 0;
}
return (size_t)bytes;
}
Sint64 Android_JNI_FileWrite(SDL_RWops *ctx, const void *buffer, Sint64 size)
size_t Android_JNI_FileWrite(SDL_RWops *ctx, const void *buffer, size_t size)
{
return SDL_SetError("Cannot write to Android package filesystem");
}