| 324 | } |
| 325 | |
| 326 | AssetFileOpenResult OpenAssetFile(u8string_view path) |
| 327 | { |
| 328 | if (!String::startsWith(path, Platform::kAndroidAssetPathPrefix)) |
| 329 | { |
| 330 | return AssetFileOpenResult{ AssetCheckResult::notApplicable, nullptr, 0 }; |
| 331 | } |
| 332 | |
| 333 | auto assetManager = static_cast<AAssetManager*>(GetAssetManager()); |
| 334 | if (assetManager == nullptr) |
| 335 | { |
| 336 | return AssetFileOpenResult{ AssetCheckResult::notFound, nullptr, 0 }; |
| 337 | } |
| 338 | |
| 339 | std::string assetPath = std::string(path.substr(Platform::kAndroidAssetPathPrefix.length())); |
| 340 | auto asset = AAssetManager_open(assetManager, assetPath.c_str(), AASSET_MODE_RANDOM); |
| 341 | if (asset == nullptr) |
| 342 | { |
| 343 | return AssetFileOpenResult{ AssetCheckResult::notFound, nullptr, 0 }; |
| 344 | } |
| 345 | |
| 346 | uint64_t assetSize = AAsset_getLength64(asset); |
| 347 | return AssetFileOpenResult{ AssetCheckResult::found, asset, assetSize }; |
| 348 | } |
| 349 | |
| 350 | void CloseAssetFile(AssetHandle handle) |
| 351 | { |
nothing calls this directly
no test coverage detected