MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / enumerateMods

Function enumerateMods

tools/launcher/launcherwindow.cpp:21–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19using namespace OpenApoc;
20
21static std::list<std::pair<UString, ModInfo>> enumerateMods()
22{
23 fs::path modPath = Options::modPath.get();
24 if (!fs::is_directory(modPath))
25 {
26 LogError("Mod path \"%s\" not a valid directory", modPath.string());
27 return {};
28 }
29
30 std::list<std::pair<UString, ModInfo>> foundMods;
31
32 for (const auto &dentry : fs::directory_iterator(modPath))
33 {
34 // Skip any non-directories
35 if (!fs::is_directory(dentry))
36 continue;
37 auto path = dentry.path();
38 auto modInfo = ModInfo::getInfo(path.string());
39 // Skip anything without a valid modinfo.xml
40 if (!modInfo)
41 continue;
42 // Otherwise store the directory/modinfo pair
43 foundMods.push_back({fs::relative(path, modPath).string(), *modInfo});
44 }
45
46 return foundMods;
47}
48
49constexpr std::array<QSize, 6> default_resolutions = {
50

Callers 5

setupModListMethod · 0.85
enabledModSelectedMethod · 0.85
disabledModSelectedMethod · 0.85
rebuildModListMethod · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected