diff options
| author | raysan5 <[email protected]> | 2020-04-05 17:51:27 +0200 |
|---|---|---|
| committer | raysan5 <[email protected]> | 2020-04-05 17:51:27 +0200 |
| commit | 90fb53bccc90ab7e3d24f8d8b9a6687098a8f739 (patch) | |
| tree | 2d4f4fcca58f74fefebd9b4381c9444a3af6adf0 /src/utils.c | |
| parent | 4ceb4d3bf3780a8a1c85b89415879799bf81d422 (diff) | |
| download | raylib-90fb53bccc90ab7e3d24f8d8b9a6687098a8f739.tar.gz raylib-90fb53bccc90ab7e3d24f8d8b9a6687098a8f739.zip | |
Review android_fopen() to support SDCard access
Diffstat (limited to 'src/utils.c')
| -rw-r--r-- | src/utils.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/utils.c b/src/utils.c index 5ba8b007..02a53abc 100644 --- a/src/utils.c +++ b/src/utils.c @@ -318,8 +318,18 @@ FILE *android_fopen(const char *fileName, const char *mode) // NOTE: AAsset provides access to read-only asset AAsset *asset = AAssetManager_open(assetManager, fileName, AASSET_MODE_UNKNOWN); - if (asset != NULL) return funopen(asset, android_read, android_write, android_seek, android_close); - else return NULL; + if (asset != NULL) + { + // Return pointer to file in the assets + return funopen(asset, android_read, android_write, android_seek, android_close); + } + else + { + #undef fopen + // Just do a regular open if file is not found in the assets + return fopen(TextFormat("%s/%s", internalDataPath, fileName), mode); + #define fopen(name, mode) android_fopen(name, mode) + } } } #endif // PLATFORM_ANDROID |
