if I only load file from apk or ipa, SDL_RWFromFile can’t do it.
so please add SDL_RWFromFileByPlatform function to resolve it
SDL_RWops *
SDL_RWFromFileByPlatform(const char *file, const char *mode)
{
SDL_RWops *rwops = NULL;
if (!file || !*file || !mode || !*mode) {
SDL_SetError("SDL_RWFromFile(): No file or no mode specified");
return NULL;
}
#if defined(ANDROID)
/* Try to open the file from the asset system */
rwops = SDL_AllocRW();
if (!rwops)
return NULL; /* SDL_SetError already setup by SDL_AllocRW() */
if (Android_JNI_FileOpen(rwops, file, mode) < 0) {
SDL_FreeRW(rwops);
return NULL;
}
rwops->size = Android_JNI_FileSize;
rwops->seek = Android_JNI_FileSeek;
rwops->read = Android_JNI_FileRead;
rwops->write = Android_JNI_FileWrite;
rwops->close = Android_JNI_FileClose;
rwops->type = SDL_RWOPS_JNIFILE;
#elif defined(__WIN32__)
rwops = SDL_AllocRW();
if (!rwops)
return NULL; /* SDL_SetError already setup by SDL_AllocRW() */
if (windows_file_open(rwops, file, mode) < 0) {
SDL_FreeRW(rwops);
return NULL;
}
rwops->size = windows_file_size;
rwops->seek = windows_file_seek;
rwops->read = windows_file_read;
rwops->write = windows_file_write;
rwops->close = windows_file_close;
rwops->type = SDL_RWOPS_WINFILE;
#elif HAVE_STDIO_H
{
#ifdef __APPLE__
FILE *fp = SDL_OpenFPFromBundleOrFallback(file, mode);
#elif __WINRT__
FILE *fp = NULL;
fopen_s(&fp, file, mode);
#else
FILE *fp = fopen(file, mode);
#endif
if (fp == NULL) {
SDL_SetError("Couldn't open %s", file);
} else {
rwops = SDL_RWFromFP(fp, 1);
}
}
#else
SDL_SetError("SDL not compiled with stdio support");
#endif /* !HAVE_STDIO_H */
return rwops;
}
...