src/file/SDL_rwops.c
changeset 5582 1281a3f1f0a6
parent 5535 96594ac5fd1a
child 6138 4c64952a58fb
     1.1 --- a/src/file/SDL_rwops.c	Wed Jul 27 18:07:40 2011 -0400
     1.2 +++ b/src/file/SDL_rwops.c	Fri Jul 29 16:51:25 2011 -0400
     1.3 @@ -31,6 +31,10 @@
     1.4  #include "cocoa/SDL_rwopsbundlesupport.h"
     1.5  #endif /* __APPLE__ */
     1.6  
     1.7 +#ifdef ANDROID
     1.8 +#include "../core/android/SDL_android.h"
     1.9 +#endif
    1.10 +
    1.11  #ifdef __NDS__
    1.12  /* include libfat headers for fatInitDefault(). */
    1.13  #include <fat.h>
    1.14 @@ -441,7 +445,20 @@
    1.15          SDL_SetError("SDL_RWFromFile(): No file or no mode specified");
    1.16          return NULL;
    1.17      }
    1.18 -#if defined(__WIN32__)
    1.19 +#if defined(ANDROID)
    1.20 +    rwops = SDL_AllocRW();
    1.21 +    if (!rwops)
    1.22 +        return NULL;            /* SDL_SetError already setup by SDL_AllocRW() */
    1.23 +    if (Android_JNI_FileOpen(rwops, file, mode) < 0) {
    1.24 +        SDL_FreeRW(rwops);
    1.25 +        return NULL;
    1.26 +    }
    1.27 +    rwops->seek = Android_JNI_FileSeek;
    1.28 +    rwops->read = Android_JNI_FileRead;
    1.29 +    rwops->write = Android_JNI_FileWrite;
    1.30 +    rwops->close = Android_JNI_FileClose;
    1.31 +
    1.32 +#elif defined(__WIN32__)
    1.33      rwops = SDL_AllocRW();
    1.34      if (!rwops)
    1.35          return NULL;            /* SDL_SetError already setup by SDL_AllocRW() */