MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / discoverInstances

Method discoverInstances

launcher/InstanceList.cpp:381–411  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

379}
380
381QList<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
413InstanceList::InstListError InstanceList::loadList()
414{

Callers

nothing calls this directly

Calls 6

PathCombineFunction · 0.85
nextMethod · 0.80
existsMethod · 0.80
appendMethod · 0.80
beginMethod · 0.80
endMethod · 0.80

Tested by

no test coverage detected