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

Method Open

engine/Poseidon/IO/FileServer.cpp:128–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126}
127
128void FileCache::Open(QIFStream& stream, const char* name)
129{
130 if (!name || !*name)
131 {
132 // Opening an empty/null name is a benign "no resource" request — e.g. a
133 // profile with no custom squad logo / voice sample set. The stream is left
134 // in its failed state for the caller to handle; this is not an asset error,
135 // so it must not be logged at ERROR (which would abort the app under --strict
136 // on a perfectly normal profile open).
137 LOG_DEBUG(Core, "FileCache::Open: empty name — no resource requested (no-op)");
138 return;
139 }
140
141 if (GEnableCaching)
142 {
143 // note: multiple threads may open file same time
144 // make sure file is in cache
145 int index = Load(name);
146 if (index >= 0)
147 {
148 // it must be the first file
149 PoseidonAssert(index == 0);
150 PoseidonAssert(!strcmp(name, _cache[index]->_name));
151 // share cached data
152 stream = _cache[index]->_data;
153 }
154 else
155 {
156 // Load already logged a "file not found" warning with the same name;
157 // include it here too so the error line carries enough context on its own.
158 LOG_ERROR(Core, "FileCache: Cache failure loading '{}' (file not found or stream fail)", name);
159 }
160 }
161 else
162 {
163 QIFStreamB temp;
164 temp.AutoOpen(name);
165 stream = temp;
166 }
167}
168
169void FileCache::Store(QIFStreamB& stream, const char* name)
170{

Callers 7

ToggleOpenMethod · 0.45
SlurpFileFunction · 0.45
InitMethod · 0.45
GetMipmapDataMethod · 0.45
LoadMethod · 0.45
GetPixelMethod · 0.45
AUTO_STATIC_ARRAYFunction · 0.45

Calls 4

AutoOpenMethod · 0.80
StoreMethod · 0.80
IsLoadedMethod · 0.45
DeleteMethod · 0.45

Tested by

no test coverage detected