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

Function getDataContents

src/Engine/CrossPlatform.cpp:555–591  ·  view source on GitHub ↗

* Gets the name of all the files * contained in a Data subfolder. * Repeated files are ignored. * @param folder Path to the data folder. * @param ext Extension of files ("" if it doesn't matter). * @return Ordered list of all the files. */

Source from the content-addressed store, hash-verified

553 * @return Ordered list of all the files.
554 */
555std::vector<std::string> getDataContents(const std::string &folder, const std::string &ext)
556{
557 std::set<std::string> unique;
558 std::vector<std::string> files;
559
560 // Check current data path
561 std::string current = caseInsensitiveFolder(Options::getDataFolder(), folder);
562 if (current != "")
563 {
564 std::vector<std::string> contents = getFolderContents(current, ext);
565 for (std::vector<std::string>::const_iterator file = contents.begin(); file != contents.end(); ++file)
566 {
567 unique.insert(*file);
568 }
569 }
570
571 // Check every other path
572 for (std::vector<std::string>::const_iterator i = Options::getDataList().begin(); i != Options::getDataList().end(); ++i)
573 {
574 std::string path = caseInsensitiveFolder(*i, folder);
575 if (path == current)
576 {
577 continue;
578 }
579 if (path != "")
580 {
581 std::vector<std::string> contents = getFolderContents(path, ext);
582 for (std::vector<std::string>::const_iterator file = contents.begin(); file != contents.end(); ++file)
583 {
584 unique.insert(*file);
585 }
586 }
587 }
588
589 files = std::vector<std::string>(unique.begin(), unique.end());
590 return files;
591}
592
593/**
594 * Checks if a certain path exists and is a folder.

Callers 1

OptionsModsStateMethod · 0.85

Calls 3

caseInsensitiveFolderFunction · 0.85
getFolderContentsFunction · 0.85
getDataFolderFunction · 0.70

Tested by

no test coverage detected