refactor into files
This commit is contained in:
21
src/main/cpp/assets_manager.cpp
Normal file
21
src/main/cpp/assets_manager.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include "assets_manager.h"
|
||||
#include <android/asset_manager.h>
|
||||
|
||||
void AssetsManager::Init(AAssetManager *asset_manager)
|
||||
{
|
||||
m_asset_manager = asset_manager;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> AssetsManager::ReadAll(const std::string &filename)
|
||||
{
|
||||
if (AAsset* asset = AAssetManager_open(m_asset_manager,
|
||||
filename.c_str(), AASSET_MODE_BUFFER))
|
||||
{
|
||||
const auto size = AAsset_getLength(asset);
|
||||
auto buffer = std::vector<uint8_t>(size);
|
||||
AAsset_read(asset, buffer.data(), size);
|
||||
AAsset_close(asset);
|
||||
return buffer;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
Reference in New Issue
Block a user