MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / findAsset

Function findAsset

Source/Engine/Content/Content.cpp:1542–1619  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1540#if ENABLE_ASSETS_DISCOVERY
1541
1542bool findAsset(const Guid& id, const String& directory, Array<String>& tmpCache, AssetInfo& info)
1543{
1544 // Get all asset files
1545 tmpCache.Clear();
1546 if (FileSystem::DirectoryGetFiles(tmpCache, directory))
1547 {
1548 if (FileSystem::DirectoryExists(directory))
1549 LOG(Error, "Cannot query files in folder '{0}'.", directory);
1550 return false;
1551 }
1552
1553 // Start searching for asset with given ID
1554 bool result = false;
1555 LOG(Info, "Start searching asset with ID: {0} in '{1}'. {2} potential files to check...", id, directory, tmpCache.Count());
1556 for (int32 i = 0; i < tmpCache.Count(); i++)
1557 {
1558 String& path = tmpCache[i];
1559
1560 // Check if not already in registry
1561 // Note: maybe we could disable this check? it would slow down searching but we will find more workspace problems
1562 if (!Cache.HasAsset(path))
1563 {
1564 auto extension = FileSystem::GetExtension(path).ToLower();
1565
1566 // Check if it's a binary asset
1567 if (ContentStorageManager::IsFlaxStorageExtension(extension))
1568 {
1569 // Skip packages in editor (results in conflicts with build game packages if deployed inside project folder)
1570#if USE_EDITOR
1571 if (extension == PACKAGE_FILES_EXTENSION)
1572 continue;
1573#endif
1574
1575 // Open storage
1576 auto storage = ContentStorageManager::GetStorage(path);
1577 if (storage)
1578 {
1579 // Register assets
1580 Cache.RegisterAssets(storage);
1581
1582 // Check if that is a missing asset
1583 if (storage->HasAsset(id))
1584 {
1585 // Found
1586 result = Cache.FindAsset(id, info);
1587 LOG(Info, "Found {1} at '{0}'!", id, path);
1588 }
1589 }
1590 else
1591 {
1592 LOG(Error, "Cannot open file '{0}' error code: {1}", path, 0);
1593 }
1594 }
1595 // Check for json resource
1596 else if (JsonStorageProxy::IsValidExtension(extension))
1597 {
1598 // Check Json storage layer
1599 Guid jsonId;

Callers 2

FindAssetsFunction · 0.85
GetAssetInfoMethod · 0.85

Calls 7

RegisterAssetsMethod · 0.80
RegisterAssetMethod · 0.80
ClearMethod · 0.45
CountMethod · 0.45
HasAssetMethod · 0.45
ToLowerMethod · 0.45
FindAssetMethod · 0.45

Tested by

no test coverage detected