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

Method Init

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

Source from the content-addressed store, hash-verified

30}
31
32void AssetsCache::Init()
33{
34 PROFILE_CPU();
35 Entry e;
36 int32 count;
37 Stopwatch stopwatch;
38#if USE_EDITOR
39 _path = Globals::ProjectCacheFolder / TEXT("AssetsCache.dat");
40#else
41 _path = Globals::ProjectContentFolder / TEXT("AssetsCache.dat");
42#endif
43 LOG(Info, "Loading Asset Cache {0}...", _path);
44
45 // Check if assets registry exists
46 if (!FileSystem::FileExists(_path))
47 {
48 _isDirty = true;
49 LOG(Warning, "Cannot find assets cache file");
50 return;
51 }
52
53 // Open file
54 FileReadStream* stream = FileReadStream::Open(_path);
55 DeleteMe<FileReadStream> deleteStream(stream);
56
57 // Load version
58 int32 version;
59 stream->Read(version);
60 if (version != FLAXENGINE_VERSION_BUILD)
61 {
62 LOG(Warning, "Corrupted or not supported Asset Cache file. Version: {0}", version);
63 return;
64 }
65
66 // Load paths
67 String enginePath, projectPath;
68 stream->Read(enginePath, -410);
69 stream->Read(projectPath, -410);
70
71 // Flags
72 AssetsCacheFlags flags;
73 stream->Read((int32&)flags);
74
75 // Check if other workspace instance used this cache
76 if (EnumHasNoneFlags(flags, AssetsCacheFlags::RelativePaths) && enginePath != Globals::StartupFolder)
77 {
78 LOG(Warning, "Assets cache generated by the different {1} installation in \'{0}\'", enginePath, TEXT("engine"));
79 return;
80 }
81 if (EnumHasNoneFlags(flags, AssetsCacheFlags::RelativePaths) && projectPath != Globals::ProjectFolder)
82 {
83 LOG(Warning, "Assets cache generated by the different {1} installation in \'{0}\'", projectPath, TEXT("project"));
84 return;
85 }
86
87 ASSETS_CACHE_LOCK();
88 _isDirty = false;
89

Callers

nothing calls this directly

Calls 12

EnumHasNoneFlagsFunction · 0.85
EnumHasAnyFlagsFunction · 0.85
StringViewClass · 0.50
ReadMethod · 0.45
ClearMethod · 0.45
EnsureCapacityMethod · 0.45
HasCharsMethod · 0.45
AddMethod · 0.45
ReadInt32Method · 0.45
DeleteMethod · 0.45
StopMethod · 0.45
CountMethod · 0.45

Tested by

no test coverage detected