MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / caseInsensitiveFolder

Function caseInsensitiveFolder

src/Engine/CrossPlatform.cpp:351–380  ·  view source on GitHub ↗

* Takes a path and tries to find it based on the * system's case-sensitivity. * @param base Base unaltered path. * @param path Full path to check for casing. * @return Correct foldername or "" if it doesn't exist. * @note There's no actual method for figuring out the correct * foldername on case-sensitive systems, this is just a workaround. */

Source from the content-addressed store, hash-verified

349 * foldername on case-sensitive systems, this is just a workaround.
350 */
351std::string caseInsensitiveFolder(const std::string &base, const std::string &path)
352{
353 std::string fullPath = base + path, newPath = path;
354
355 // Try all various case mutations
356 // Normal unmangled
357 if (folderExists(fullPath.c_str()))
358 {
359 return fullPath;
360 }
361
362 // UPPERCASE
363 std::transform(newPath.begin(), newPath.end(), newPath.begin(), toupper);
364 fullPath = base + newPath;
365 if (folderExists(fullPath.c_str()))
366 {
367 return fullPath;
368 }
369
370 // lowercase
371 std::transform(newPath.begin(), newPath.end(), newPath.begin(), tolower);
372 fullPath = base + newPath;
373 if (folderExists(fullPath.c_str()))
374 {
375 return fullPath;
376 }
377
378 // If we got here nothing can help us
379 return "";
380}
381
382/**
383 * Takes a filename and tries to find it in the game's Data folders,

Callers 2

getDataFolderFunction · 0.85
getDataContentsFunction · 0.85

Calls 1

folderExistsFunction · 0.85

Tested by

no test coverage detected