| 29 | namespace Packwiz { |
| 30 | |
| 31 | auto getRealIndexName(QDir& index_dir, QString normalized_fname, bool should_find_match) -> QString |
| 32 | { |
| 33 | QFile index_file(index_dir.absoluteFilePath(normalized_fname)); |
| 34 | |
| 35 | QString real_fname = normalized_fname; |
| 36 | if (!index_file.exists()) { |
| 37 | // Tries to get similar entries |
| 38 | for (auto& file_name : index_dir.entryList(QDir::Filter::Files)) { |
| 39 | if (!QString::compare(normalized_fname, file_name, Qt::CaseInsensitive)) { |
| 40 | real_fname = file_name; |
| 41 | break; |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | if (should_find_match && !QString::compare(normalized_fname, real_fname, Qt::CaseSensitive)) { |
| 46 | qCritical() << "Could not find a match for a valid metadata file!"; |
| 47 | qCritical() << "File: " << normalized_fname; |
| 48 | return {}; |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | return real_fname; |
| 53 | } |
| 54 | |
| 55 | // Helpers |
| 56 | static inline auto indexFileName(QString const& mod_slug) -> QString |
no test coverage detected