MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / OpenAssetFile

Function OpenAssetFile

src/openrct2/platform/Platform.Android.cpp:326–348  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls 2

startsWithFunction · 0.85
GetAssetManagerFunction · 0.85

Tested by

no test coverage detected