2 #include <msp/core/application.h>
3 #include <msp/core/mainthread.h>
4 #include <android/asset_manager.h>
18 Asset::Asset(const string &name)
20 AAssetManager *asset_manager = reinterpret_cast<Android::MainThread *>(Application::get_data())->get_asset_manager();
21 AAsset *asset = AAssetManager_open(asset_manager, name.c_str(), AASSET_MODE_RANDOM);
23 throw file_not_found(name);
33 AAsset_close(priv->asset);
37 unsigned Asset::do_read(char *buf, unsigned size)
39 int ret = AAsset_read(priv->asset, buf, size);
41 throw runtime_error("Asset::do_read");
48 SeekOffset Asset::seek(SeekOffset off, SeekType type)
50 signal_flush_required.emit();
51 off = AAsset_seek(priv->asset, off, type);
53 throw runtime_error("Asset::seek");
57 SeekOffset Asset::tell() const
59 SeekOffset off = AAsset_seek(priv->asset, 0, S_CUR);
61 throw runtime_error("Asset::tell");