| 179 | } |
| 180 | |
| 181 | void FileFinder_RTP::AddPath(std::string_view p) { |
| 182 | using namespace FileFinder; |
| 183 | auto fs = FileFinder::Root().Create(FileFinder::MakeCanonical(p)); |
| 184 | if (fs) { |
| 185 | auto files = fs.ListDirectory(); |
| 186 | if (files->size() == 0) { |
| 187 | Output::Debug("RTP path {} is empty, not adding", p); |
| 188 | return; |
| 189 | } |
| 190 | |
| 191 | Output::Debug("Adding {} to RTP path", p); |
| 192 | |
| 193 | auto hit_info = RTP::Detect(fs, Player::EngineVersion()); |
| 194 | |
| 195 | search_paths.push_back(fs); |
| 196 | |
| 197 | if (hit_info.empty()) { |
| 198 | Output::Debug("The folder does not contain a known RTP!"); |
| 199 | } |
| 200 | |
| 201 | // Only consider the best RTP hits (usually 100% if properly installed) |
| 202 | float best = 0.0; |
| 203 | for (const auto& hit : hit_info) { |
| 204 | float rate = static_cast<float>(hit.hits) / hit.max; |
| 205 | if (rate >= best) { |
| 206 | Output::Debug("RTP is \"{}\" ({}/{})", hit.name, hit.hits, hit.max); |
| 207 | detected_rtp.emplace_back(hit); |
| 208 | best = rate; |
| 209 | } |
| 210 | } |
| 211 | } else { |
| 212 | Output::Debug("RTP path {} is invalid, not adding", p); |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | void FileFinder_RTP::ReadRegistry(std::string_view company, std::string_view product, std::string_view key) { |
| 217 | #if defined(USE_WINE_REGISTRY) || defined(_WIN32) |
nothing calls this directly
no test coverage detected