I'm currently using NDK AssetManager_open
and AAsset_read
to read files in asset folder.
// open a file and read its content
AAsset* asset AAssetManager_open(engine.app->activity->assetManager, name.c_str(), AASSET_MODE_UNKNOWN);
if (NULL == asset) {
LOGE("_ASSET_NOT_FOUND_: %s", name.c_str());
return nullptr;
}
long size = AAsset_getLength(asset);
void* buffer = malloc(size);
AAsset_read(asset, buffer, size);
AAsset_close(asset);
NDK AAsset
offers these functions :
int AAsset_read(AAsset* asset, void* buf, size_t count);
off_t AAsset_seek(AAsset* asset, off_t offset, int whence);
void AAsset_close(AAsset* asset);
const void* AAsset_getBuffer(AAsset* asset);
off_t AAsset_getLength(AAsset* asset);
off_t AAsset_getRemainingLength(AAsset* asset);
I'm looking for a way to construct an std::istream
for an AAsset*
.
I don't want to read all of the file contents and then create the istream
.
Any idea on how to construct an istream
working on an AAsset*
?