Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Try opening relative path files from internal storage.
Browse files Browse the repository at this point in the history
I'm not falling back to external storage because the application should be
aware of whether external storage is available and choose whether or not to
use it.
  • Loading branch information
slouken committed Nov 2, 2012
1 parent 3060ad7 commit 4a3e5fc
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/file/SDL_rwops.c
Expand Up @@ -429,13 +429,28 @@ SDL_RWFromFile(const char *file, const char *mode)
#if defined(ANDROID)
#ifdef HAVE_STDIO_H
/* Try to open the file on the filesystem first */
{
if (*file == '/') {
FILE *fp = fopen(file, mode);
if (fp) {
return SDL_RWFromFP(fp, 1);
}
} else {
/* Try opening it from internal storage if it's a relative path */
char *path;
FILE *fp;

path = SDL_stack_alloc(char, PATH_MAX);
if (path) {
SDL_snprintf(path, PATH_MAX, "%s/%s",
SDL_AndroidGetInternalStoragePath(), file);
fp = fopen(path, mode);
SDL_stack_free(path);
if (fp) {
return SDL_RWFromFP(fp, 1);
}
}
}
#endif
#endif /* HAVE_STDIO_H */

/* Try to open the file from the asset system */
rwops = SDL_AllocRW();
Expand Down

0 comments on commit 4a3e5fc

Please sign in to comment.