rwops: Make read and write work like POSIX, not stdio.

This simplifies some things, clarifies some things, and also allows
for the possibility of RWops that offer non-blocking i/o (although
none of the current built-in ones do, intentionally, we could add this
later if we choose, or people could provide things like network socket
RWops implementations now, etc.

Fixes #6729.
This commit is contained in:
Ryan C. Gordon 2022-12-14 15:42:54 -05:00
parent e9a9afaded
commit 72c1f73bc5
No known key found for this signature in database
GPG key ID: FA148B892AB48044
14 changed files with 196 additions and 197 deletions

View file

@ -1846,27 +1846,15 @@ int Android_JNI_FileOpen(SDL_RWops *ctx,
return 0;
}
size_t Android_JNI_FileRead(SDL_RWops *ctx, void *buffer,
size_t size, size_t maxnum)
Sint64 Android_JNI_FileRead(SDL_RWops *ctx, void *buffer, Sint64 size)
{
size_t result;
AAsset *asset = (AAsset *)ctx->hidden.androidio.asset;
result = AAsset_read(asset, buffer, size * maxnum);
if (result > 0) {
/* Number of chuncks */
return result / size;
} else {
/* Error or EOF */
return result;
}
return (Sint64) AAsset_read(asset, buffer, (size_t) size);
}
size_t Android_JNI_FileWrite(SDL_RWops *ctx, const void *buffer,
size_t size, size_t num)
Sint64 Android_JNI_FileWrite(SDL_RWops *ctx, const void *buffer, Sint64 size)
{
SDL_SetError("Cannot write to Android package filesystem");
return 0;
return SDL_SetError("Cannot write to Android package filesystem");
}
Sint64 Android_JNI_FileSize(SDL_RWops *ctx)