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

Method IsEntryValid

Source/Engine/Content/Cache/AssetsCache.cpp:570–626  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

568#endif
569
570bool AssetsCache::IsEntryValid(Entry& e)
571{
572#if ENABLE_ASSETS_DISCOVERY
573 // Check if file exists
574 if (FileSystem::FileExists(e.Info.Path))
575 {
576 // Check if file hasn't been modified
577 const auto fileModified = FileSystem::GetFileLastEditTime(e.Info.Path);
578 if (fileModified == e.FileModified)
579 return true;
580
581 const auto extension = FileSystem::GetExtension(e.Info.Path).ToLower();
582
583 // Check if it's a binary asset
584 if (ContentStorageManager::IsFlaxStorageExtension(extension))
585 {
586 // Validate ID within storage container
587 const auto storage = ContentStorageManager::GetStorage(e.Info.Path);
588 if (storage)
589 {
590 // Check if storage at given location contains that asset
591 const bool isValid = storage->HasAsset(e.Info);
592
593 // Update entry and mark cache as dirty
594 e.FileModified = fileModified;
595 _isDirty = true;
596
597 return isValid;
598 }
599 }
600 // Check for json resource
601 else if (JsonStorageProxy::IsValidExtension(extension))
602 {
603 // Check Json storage layer
604 Guid jsonId;
605 String jsonTypeName;
606 if (JsonStorageProxy::GetAssetInfo(e.Info.Path, jsonId, jsonTypeName))
607 {
608 const bool isValid = e.Info.ID == jsonId && e.Info.TypeName == jsonTypeName;
609
610 // Update entry and mark cache as dirty
611 e.FileModified = fileModified;
612 _isDirty = true;
613
614 return isValid;
615 }
616 }
617 }
618
619 return false;
620
621#else
622 // In game we don't care about it because all cached asset entries are valid (precached)
623 // Skip only entries with missing file
624 return e.Info.Path.HasChars();
625#endif
626}

Callers

nothing calls this directly

Calls 3

ToLowerMethod · 0.45
HasAssetMethod · 0.45
HasCharsMethod · 0.45

Tested by

no test coverage detected