| 19 | using namespace OpenApoc; |
| 20 | |
| 21 | static 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 | |
| 49 | constexpr std::array<QSize, 6> default_resolutions = { |
| 50 |
no test coverage detected