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

Function getDataFolder

src/Engine/CrossPlatform.cpp:424–452  ·  view source on GitHub ↗

* Takes a foldername and tries to find it in the game's Data folders, * accounting for the system's case-sensitivity and path style. * @param foldername Original foldername. * @return Correct foldername or "" if it doesn't exist. */

Source from the content-addressed store, hash-verified

422 * @return Correct foldername or "" if it doesn't exist.
423 */
424std::string getDataFolder(const std::string &foldername)
425{
426 // Correct folder separator
427 std::string name = foldername;
428#ifdef _WIN32
429 std::replace(name.begin(), name.end(), '/', PATH_SEPARATOR);
430#endif
431
432 // Check current data path
433 std::string path = caseInsensitiveFolder(Options::getDataFolder(), name);
434 if (path != "")
435 {
436 return path;
437 }
438
439 // Check every other path
440 for (std::vector<std::string>::const_iterator i = Options::getDataList().begin(); i != Options::getDataList().end(); ++i)
441 {
442 std::string path = caseInsensitiveFolder(*i, name);
443 if (path != "")
444 {
445 Options::setDataFolder(*i);
446 return path;
447 }
448 }
449
450 // Give up
451 return foldername;
452}
453
454/**
455 * Creates a folder at the specified path.

Callers 2

getDataFileFunction · 0.70
getDataContentsFunction · 0.70

Calls 2

caseInsensitiveFolderFunction · 0.85
setDataFolderFunction · 0.85

Tested by

no test coverage detected