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

Function CheckAssetExistsInList

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

Source from the content-addressed store, hash-verified

271 }
272
273 static AssetCheckResult CheckAssetExistsInList(u8string_view path, bool directoryOnly)
274 {
275 if (!String::startsWith(path, Platform::kAndroidAssetPathPrefix))
276 {
277 return AssetCheckResult::notApplicable;
278 }
279
280 const auto& assetList = GetAssetList();
281 std::string assetPath = std::string(path.substr(Platform::kAndroidAssetPathPrefix.length()));
282 if (assetPath.empty())
283 {
284 return assetList.empty() ? AssetCheckResult::notFound : AssetCheckResult::found;
285 }
286
287 if (!directoryOnly)
288 {
289 auto it = std::lower_bound(
290 assetList.begin(), assetList.end(), assetPath,
291 [](const AssetInfo& a, const std::string& b) { return a.path < b; });
292 if (it != assetList.end() && it->path == assetPath)
293 {
294 return AssetCheckResult::found;
295 }
296 return AssetCheckResult::notFound;
297 }
298
299 // Only check for directory/prefix matches if directoryOnly is true
300 std::string prefix = assetPath;
301 if (!prefix.empty() && prefix.back() != '/')
302 {
303 prefix += '/';
304 }
305
306 auto it = std::lower_bound(
307 assetList.begin(), assetList.end(), prefix, [](const AssetInfo& a, const std::string& b) { return a.path < b; });
308 if (it != assetList.end() && String::startsWith(it->path, prefix))
309 {
310 return AssetCheckResult::found;
311 }
312
313 return AssetCheckResult::notFound;
314 }
315
316 AssetCheckResult CheckAssetDirectoryExists(u8string_view path)
317 {

Callers 2

CheckAssetExistsFunction · 0.85

Calls 5

startsWithFunction · 0.85
endMethod · 0.65
emptyMethod · 0.45
beginMethod · 0.45
backMethod · 0.45

Tested by

no test coverage detected