MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / GetScriptFileRecursive

Function GetScriptFileRecursive

Source/Scripting/scriptfile.cpp:209–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207}
208
209static const ScriptFile* GetScriptFileRecursive(const ScriptFile* parent_script_file, const Path& path) {
210 // Look in script file cache for desired script file
211 ScriptFileMap& file_map = ScriptFileCache::Instance()->files;
212 ScriptFileMap::iterator iter;
213 iter = file_map.find(path.GetFullPathStr());
214 ModID modsource;
215 if (iter == file_map.end()) {
216 // Desired script file not found, so load it
217 std::string source = ReadScriptFile(path);
218 if (!source.empty()) {
219 ScriptFile& file = file_map[path.GetFullPathStr()];
220 UpdateFile(parent_script_file, file, source, path);
221 return &file;
222 }
223 } else {
224 // Script file found -- make sure it hasn't changed
225 ScriptFile& script_file = (*iter).second;
226 if (ScriptFileUtil::DetectScriptFileChanged(path)) {
227 std::string source = ReadScriptFile(path);
228 if (!source.empty()) {
229 UpdateFile(parent_script_file, script_file, source, path);
230 return &script_file;
231 }
232 } else {
233 return &script_file;
234 }
235 }
236
237 return NULL;
238}
239
240static void InsertFileRange(FileRangeList& ranges,
241 unsigned start,

Callers 2

ExpandIncludePathsMethod · 0.85
GetScriptFileMethod · 0.85

Calls 6

ReadScriptFileFunction · 0.85
UpdateFileFunction · 0.85
GetFullPathStrMethod · 0.80
findMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected