| 379 | } |
| 380 | |
| 381 | QList<InstanceId> InstanceList::discoverInstances() |
| 382 | { |
| 383 | qDebug() << "Discovering instances in" << m_instDir; |
| 384 | QList<InstanceId> out; |
| 385 | QDirIterator iter(m_instDir, QDir::Dirs | QDir::NoDot | QDir::NoDotDot | QDir::Readable | QDir::Hidden, QDirIterator::FollowSymlinks); |
| 386 | while (iter.hasNext()) { |
| 387 | QString subDir = iter.next(); |
| 388 | QFileInfo dirInfo(subDir); |
| 389 | if (!QFileInfo(FS::PathCombine(subDir, "instance.cfg")).exists()) |
| 390 | continue; |
| 391 | // if it is a symlink, ignore it if it goes to the instance folder |
| 392 | if (dirInfo.isSymLink()) { |
| 393 | QFileInfo targetInfo(dirInfo.symLinkTarget()); |
| 394 | QFileInfo instDirInfo(m_instDir); |
| 395 | if (targetInfo.canonicalPath() == instDirInfo.canonicalFilePath()) { |
| 396 | qDebug() << "Ignoring symlink" << subDir << "that leads into the instances folder"; |
| 397 | continue; |
| 398 | } |
| 399 | } |
| 400 | auto id = dirInfo.fileName(); |
| 401 | out.append(id); |
| 402 | qDebug() << "Found instance ID" << id; |
| 403 | } |
| 404 | #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) |
| 405 | instanceSet = QSet<QString>(out.begin(), out.end()); |
| 406 | #else |
| 407 | instanceSet = out.toSet(); |
| 408 | #endif |
| 409 | m_instancesProbed = true; |
| 410 | return out; |
| 411 | } |
| 412 | |
| 413 | InstanceList::InstListError InstanceList::loadList() |
| 414 | { |