MCPcopy Create free account
hub / github.com/ZDoom/Raze / NormalizeFileName

Method NormalizeFileName

source/common/filesystem/source/resourcefile.cpp:253–282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

251//==========================================================================
252
253const char* FResourceFile::NormalizeFileName(const char* fn, int fallbackcp)
254{
255 if (!fn || !*fn) return "";
256 auto norm = tolower_normalize(fn);
257 if (!norm)
258 {
259 if (fallbackcp == 437)
260 {
261 std::vector<char> buffer;
262 ibm437_to_utf8(fn, buffer);
263 norm = tolower_normalize(buffer.data());
264 }
265 // maybe handle other codepages
266 else
267 {
268 // if the filename is not valid UTF-8, nuke all bytes larger than 0x80 so that we still got something semi-usable
269 std::string ffn = fn;
270 for (auto& c : ffn)
271 {
272 if (c & 0x80) c = '@';
273 }
274 norm = tolower_normalize(&ffn.front());
275 }
276 }
277 FixPathSeparator(norm);
278 auto pooled = stringpool->Strdup(norm);
279 free(norm);
280 return pooled;
281
282}
283
284//==========================================================================
285//

Callers 9

OpenSSIFunction · 0.80
OpenMvlFunction · 0.80
OpenLumpFunction · 0.80
OpenGrpFunction · 0.80
AddFromBufferMethod · 0.80
OpenHogFunction · 0.80
OpenWHResFunction · 0.80
OpenRFFFunction · 0.80
OpenPakFunction · 0.80

Calls 5

tolower_normalizeFunction · 0.85
ibm437_to_utf8Function · 0.85
FixPathSeparatorFunction · 0.85
dataMethod · 0.45
StrdupMethod · 0.45

Tested by

no test coverage detected