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

Method FindAsset

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

Source from the content-addressed store, hash-verified

266}
267
268bool AssetsCache::FindAsset(const StringView& path, AssetInfo& info)
269{
270 PROFILE_CPU();
271 bool result = false;
272 ASSETS_CACHE_LOCK();
273
274 // Check if asset has direct mapping to id (used for some cooked assets)
275 Guid id;
276 if (_pathsMapping.TryGet(path, id))
277 {
278 return FindAsset(id, info);
279 }
280#if !USE_EDITOR
281 if (FileSystem::IsRelative(path))
282 {
283 // Additional check if user provides path relative to the project folder (eg. Content/SomeAssets/MyFile.json)
284 const String absolutePath = Globals::ProjectFolder / *path;
285 if (_pathsMapping.TryGet(absolutePath, id))
286 {
287 return FindAsset(id, info);
288 }
289 }
290#endif
291
292 // Find asset in registry
293 for (auto i = _registry.Begin(); i.IsNotEnd(); ++i)
294 {
295 auto& e = i->Value;
296 if (e.Info.Path == path)
297 {
298 if (!IsEntryValid(e))
299 {
300 LOG(Warning, "Missing file from registry: \'{0}\':{1}:{2}", e.Info.Path, e.Info.ID, e.Info.TypeName);
301 _registry.Remove(i);
302 }
303 else
304 {
305 // Found
306 result = true;
307 info = e.Info;
308 }
309
310 break;
311 }
312 }
313
314 return result;
315}
316
317bool AssetsCache::FindAsset(const Guid& id, AssetInfo& info)
318{

Callers 2

GetAssetInfoMethod · 0.45
findAssetFunction · 0.45

Calls 5

IsRelativeFunction · 0.85
TryGetMethod · 0.45
BeginMethod · 0.45
IsNotEndMethod · 0.45
RemoveMethod · 0.45

Tested by

no test coverage detected