Review android_fopen() to support SDCard access
This commit is contained in:
parent
4ceb4d3bf3
commit
90fb53bccc
1 changed files with 12 additions and 2 deletions
14
src/utils.c
14
src/utils.c
|
@ -318,8 +318,18 @@ FILE *android_fopen(const char *fileName, const char *mode)
|
||||||
// NOTE: AAsset provides access to read-only asset
|
// NOTE: AAsset provides access to read-only asset
|
||||||
AAsset *asset = AAssetManager_open(assetManager, fileName, AASSET_MODE_UNKNOWN);
|
AAsset *asset = AAssetManager_open(assetManager, fileName, AASSET_MODE_UNKNOWN);
|
||||||
|
|
||||||
if (asset != NULL) return funopen(asset, android_read, android_write, android_seek, android_close);
|
if (asset != NULL)
|
||||||
else return 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
|
#endif // PLATFORM_ANDROID
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue