src/file/SDL_rwops.c
changeset 6633 e36b94438fcf
parent 6629 8e2c731103e6
child 6642 b716011e53ce
equal deleted inserted replaced
6632:147f85ac2e4b 6633:e36b94438fcf
   427         return NULL;
   427         return NULL;
   428     }
   428     }
   429 #if defined(ANDROID)
   429 #if defined(ANDROID)
   430 #ifdef HAVE_STDIO_H
   430 #ifdef HAVE_STDIO_H
   431     /* Try to open the file on the filesystem first */
   431     /* Try to open the file on the filesystem first */
   432     {
   432     if (*file == '/') {
   433         FILE *fp = fopen(file, mode);
   433         FILE *fp = fopen(file, mode);
   434         if (fp) {
   434         if (fp) {
   435             return SDL_RWFromFP(fp, 1);
   435             return SDL_RWFromFP(fp, 1);
   436         }
   436         }
   437     }
   437     } else {
   438 #endif
   438         /* Try opening it from internal storage if it's a relative path */
       
   439         char *path;
       
   440         FILE *fp;
       
   441 
       
   442         path = SDL_stack_alloc(char, PATH_MAX);
       
   443         if (path) {
       
   444             SDL_snprintf(path, PATH_MAX, "%s/%s",
       
   445                          SDL_AndroidGetInternalStoragePath(), file);
       
   446             fp = fopen(path, mode);
       
   447             SDL_stack_free(path);
       
   448             if (fp) {
       
   449                 return SDL_RWFromFP(fp, 1);
       
   450             }
       
   451         }
       
   452     }
       
   453 #endif /* HAVE_STDIO_H */
   439 
   454 
   440     /* Try to open the file from the asset system */
   455     /* Try to open the file from the asset system */
   441     rwops = SDL_AllocRW();
   456     rwops = SDL_AllocRW();
   442     if (!rwops)
   457     if (!rwops)
   443         return NULL;            /* SDL_SetError already setup by SDL_AllocRW() */
   458         return NULL;            /* SDL_SetError already setup by SDL_AllocRW() */