mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-06-04 19:07:40 +00:00
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:
parent
e9a9afaded
commit
72c1f73bc5
14 changed files with 196 additions and 197 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue