MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / Load

Method Load

engine/Poseidon/IO/FileServer.cpp:92–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90}
91
92int FileCache::Load(const char* name)
93{
94 // search the cache
95 int index = Find(name);
96 if (index >= 0)
97 {
98 if (index != 0)
99 {
100 MoveToFront(index);
101 }
102 return 0;
103 }
104 // not cached yet
105 FileInCache* newEntry = new FileInCache(name);
106 if (newEntry->_data.fail())
107 {
108 delete newEntry;
109 // RptF is a no-op in release builds — surface the missing file through the
110 // normal log so callers can see WHICH file the subsequent Cache failure is for.
111 LOG_WARN(Core, "FileCache: file '{}' not found", name);
112 return -1;
113 }
114 _cache.Insert(0, newEntry);
115 PoseidonAssert(newEntry->_data.tellg() == 0);
116 // maintain size statistics
117 _size += newEntry->_data.rest();
118 Maintain();
119 return 0;
120}
121
122bool FileCache::IsLoaded(const char* name)
123{

Callers 1

LoadKeysMethod · 0.45

Calls 5

FindFunction · 0.85
tellgMethod · 0.80
restMethod · 0.80
failMethod · 0.45
InsertMethod · 0.45

Tested by

no test coverage detected