| 266 | } |
| 267 | |
| 268 | bool 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 | |
| 317 | bool AssetsCache::FindAsset(const Guid& id, AssetInfo& info) |
| 318 | { |
no test coverage detected