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

Method Load

Source/Editor/Cooker/Steps/CookAssetsStep.cpp:131–293  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129}
130
131void CookAssetsStep::CacheData::Load(CookingData& data)
132{
133 PROFILE_CPU();
134 HeaderFilePath = data.CacheDirectory / String::Format(TEXT("CookedHeader_{0}.bin"), FLAXENGINE_VERSION_BUILD);
135 CacheFolder = data.CacheDirectory / TEXT("Cooked");
136 Entries.Clear();
137
138 if (!FileSystem::DirectoryExists(CacheFolder))
139 FileSystem::CreateDirectory(CacheFolder);
140 if (!FileSystem::FileExists(HeaderFilePath))
141 return;
142
143 auto file = FileReadStream::Open(HeaderFilePath);
144 if (file == nullptr)
145 return;
146 DeleteMe<FileReadStream> deleteFile(file);
147
148 int32 buildNum;
149 file->ReadInt32(&buildNum);
150 if (buildNum != FLAXENGINE_VERSION_BUILD)
151 return;
152 int32 entriesCount;
153 file->ReadInt32(&entriesCount);
154 if (Math::IsNotInRange(entriesCount, 0, 1000000))
155 return;
156
157 LOG(Info, "Loading incremental build cooking cache (entries count: {0})", entriesCount);
158 file->ReadBytes(&Settings, sizeof(Settings));
159 Entries.EnsureCapacity(entriesCount);
160
161 Array<Pair<String, DateTime>> fileDependencies;
162 for (int32 i = 0; i < entriesCount; i++)
163 {
164 Guid id;
165 file->Read(id);
166 String typeName;
167 file->Read(typeName);
168 DateTime fileModified;
169 file->Read(fileModified);
170 int32 fileDependenciesCount;
171 file->ReadInt32(&fileDependenciesCount);
172 fileDependencies.Clear();
173 fileDependencies.Resize(fileDependenciesCount);
174 for (int32 j = 0; j < fileDependenciesCount; j++)
175 {
176 Pair<String, DateTime>& f = fileDependencies[j];
177 file->Read(f.First, 10);
178 file->Read(f.Second);
179 }
180
181 // Skip missing entries
182 if (!FileSystem::FileExists(CacheFolder / id.ToString(Guid::FormatType::N)))
183 continue;
184
185 auto& e = Entries[id];
186 e.ID = id;
187 e.TypeName = typeName;
188 e.FileModified = fileModified;

Callers 9

AddMethod · 0.45
PerformMethod · 0.45
CreateMethod · 0.45
CreateMethod · 0.45
CreateMethod · 0.45
CreateMethod · 0.45
InitializeMethod · 0.45
UpdateMaterialMethod · 0.45

Calls 14

IsNotInRangeFunction · 0.85
FormatFunction · 0.50
ToSpanFunction · 0.50
GetFunction · 0.50
ClearMethod · 0.45
ReadInt32Method · 0.45
ReadBytesMethod · 0.45
EnsureCapacityMethod · 0.45
ReadMethod · 0.45
ResizeMethod · 0.45
ToStringMethod · 0.45
LoadCacheMethod · 0.45

Tested by

no test coverage detected