@@ -4,16 +4,15 @@ using namespace nbl;
4
4
using namespace nbl ::system;
5
5
6
6
#ifdef _NBL_PLATFORM_ANDROID_
7
- #include < jni.h>
8
7
#include < android/native_activity.h>
9
8
#include < android/asset_manager.h>
10
9
11
- CAPKResourcesArchive::CAPKResourcesArchive (const path& _path, system::logger_opt_smart_ptr&& logger, ANativeActivity* act, JNIEnv* jni )
12
- : CFileArchive(path(_path),std::move(logger),computeItems(_path.string())), m_mgr(act->assetManager), m_activity(act), m_jniEnv(jni )
10
+ CAPKResourcesArchive::CAPKResourcesArchive (const path& _path, system::logger_opt_smart_ptr&& logger, ANativeActivity* act, JNIEnv* jniEnv )
11
+ : CFileArchive(path(_path),std::move(logger),computeItems(_path.string(),act->assetManager,jniEnv )), m_mgr(act->assetManager), m_activity(act)
13
12
{
14
13
}
15
14
16
- core::vector<IFileArchive::SListEntry> CAPKResourcesArchive::computeItems (const std::string& asset_path)
15
+ core::vector<IFileArchive::SListEntry> CAPKResourcesArchive::computeItems (const std::string& asset_path, AAssetManager* mgr, JNIEnv* env )
17
16
{
18
17
auto context_object = activity->clazz ;
19
18
auto getAssets_method = env->GetMethodID (env->GetObjectClass (context_object), " getAssets" , " ()Landroid/content/res/AssetManager;" );
@@ -39,7 +38,7 @@ core::vector<IFileArchive::SListEntry> CAPKResourcesArchive::computeItems(const
39
38
auto & item = result.emplace_back ();
40
39
item.pathRelativeToArchive = filename;
41
40
{
42
- AAsset* asset = AAssetManager_open (m_mgr ,filename,AASSET_MODE_STREAMING);
41
+ AAsset* asset = AAssetManager_open (mgr ,filename,AASSET_MODE_STREAMING);
43
42
item.size = AAsset_getLength (asset);
44
43
AAsset_close (asset);
45
44
}
@@ -57,7 +56,7 @@ core::vector<IFileArchive::SListEntry> CAPKResourcesArchive::computeItems(const
57
56
CFileArchive::file_buffer_t CAPKResourcesArchive::getFileBuffer (const IFileArchive::SListEntry* item)
58
57
{
59
58
AAsset* asset = AAssetManager_open (m_mgr,item->pathRelativeToArchive .string ().c_str (),AASSET_MODE_BUFFER);
60
- return {const_cast <void *>(AAsset_getBuffer (asset)),AAsset_getLength (asset),asset};
59
+ return {const_cast <void *>(AAsset_getBuffer (asset)),static_cast < size_t >( AAsset_getLength (asset) ),asset};
61
60
}
62
61
63
62
#endif
0 commit comments