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

Function getDataFile

src/Engine/CrossPlatform.cpp:388–416  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

386 * @return Correct filename or "" if it doesn't exist.
387 */
388std::string getDataFile(const std::string &filename)
389{
390 // Correct folder separator
391 std::string name = filename;
392#ifdef _WIN32
393 std::replace(name.begin(), name.end(), '/', PATH_SEPARATOR);
394#endif
395
396 // Check current data path
397 std::string path = caseInsensitive(Options::getDataFolder(), name);
398 if (path != "")
399 {
400 return path;
401 }
402
403 // Check every other path
404 for (std::vector<std::string>::const_iterator i = Options::getDataList().begin(); i != Options::getDataList().end(); ++i)
405 {
406 std::string path = caseInsensitive(*i, name);
407 if (path != "")
408 {
409 Options::setDataFolder(*i);
410 return path;
411 }
412 }
413
414 // Give up
415 return filename;
416}
417
418/**
419 * Takes a foldername and tries to find it in the game's Data folders,

Callers 15

resetDisplayMethod · 0.85
loadMethod · 0.85
loadLanguageMethod · 0.85
setWindowIconFunction · 0.85
loadMAPMethod · 0.85
loadRMPMethod · 0.85
initMethod · 0.85
XcomResourcePackMethod · 0.85
loadMusicMethod · 0.85
loadMethod · 0.85
loadMethod · 0.85

Calls 3

caseInsensitiveFunction · 0.85
setDataFolderFunction · 0.85
getDataFolderFunction · 0.70

Tested by

no test coverage detected