| 305 | } |
| 306 | |
| 307 | bool FlaxStorage::Load() |
| 308 | { |
| 309 | if (IsLoaded()) |
| 310 | return false; |
| 311 | PROFILE_MEM(ContentFiles); |
| 312 | ScopeLock lock(_loadLocker); |
| 313 | if (IsLoaded()) |
| 314 | return false; |
| 315 | ASSERT(GetEntriesCount() == 0); |
| 316 | |
| 317 | // Open file |
| 318 | auto stream = OpenFile(); |
| 319 | if (stream == nullptr) |
| 320 | return true; |
| 321 | |
| 322 | // Magic Code |
| 323 | uint32 magicCode; |
| 324 | stream->ReadUint32(&magicCode); |
| 325 | if (magicCode != MagicCode) |
| 326 | { |
| 327 | LOG(Warning, "Invalid asset magic code in {0}", ToString()); |
| 328 | return true; |
| 329 | } |
| 330 | |
| 331 | // Version |
| 332 | uint32 version; |
| 333 | stream->ReadUint32(&version); |
| 334 | switch (version) |
| 335 | { |
| 336 | case 9: |
| 337 | { |
| 338 | // Custom storage data |
| 339 | CustomData customData; |
| 340 | stream->Read(customData); |
| 341 | |
| 342 | #if USE_EDITOR |
| 343 | // Block loading packaged games content |
| 344 | if (customData.ContentKey != 0) |
| 345 | #else |
| 346 | // Block load content from unknown sources |
| 347 | if (customData.ContentKey != Globals::ContentKey) |
| 348 | #endif |
| 349 | { |
| 350 | LOG(Warning, "Invalid asset {0}.", ToString()); |
| 351 | return true; |
| 352 | } |
| 353 | |
| 354 | // Entries |
| 355 | int32 assetsCount; |
| 356 | stream->ReadInt32(&assetsCount); |
| 357 | for (int32 i = 0; i < assetsCount; i++) |
| 358 | { |
| 359 | SerializedEntryV9 se; |
| 360 | stream->ReadBytes(&se, sizeof(se)); |
| 361 | Entry e(se.ID, se.TypeName.Data, se.Address); |
| 362 | AddEntry(e); |
| 363 | } |
| 364 |
no test coverage detected