Created
December 2, 2013 11:32
-
-
Save xxxzhi/7748232 to your computer and use it in GitHub Desktop.
From http://stackoverflow.com/questions/13317387/how-to-get-file-in-assets-from-android-ndk ndk fopen assert file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AAssetDir* assetDir = AAssetManager_openDir(mgr, ""); | |
const char* filename = (const char*)NULL; | |
while ((filename = AAssetDir_getNextFileName(assetDir)) != NULL) { | |
AAsset* asset = AAssetManager_open(mgr, filename, AASSET_MODE_STREAMING); | |
char buf[BUFSIZ]; | |
int nb_read = 0; | |
FILE* out = fopen(filename, "w"); | |
while ((nb_read = AAsset_read(asset, buf, BUFSIZ)) > 0) | |
fwrite(buf, nb_read, 1, out); | |
fclose(out); | |
AAsset_close(asset); | |
} | |
AAssetDir_close(assetDir); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment