MCPcopy Create free account
hub / github.com/ModOrganizer2/modorganizer / addMultipleModsFilesToStructure

Method addMultipleModsFilesToStructure

src/directoryrefresher.cpp:390–453  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

388}
389
390void DirectoryRefresher::addMultipleModsFilesToStructure(
391 MOShared::DirectoryEntry* directoryStructure, const std::vector<EntryInfo>& entries,
392 DirectoryRefreshProgress* progress)
393{
394 std::vector<DirectoryStats> stats(entries.size());
395
396 if (progress) {
397 progress->start(entries.size());
398 }
399
400 log::debug("refresher: using {} threads", m_threadCount);
401 g_threads.setMax(m_threadCount);
402
403 for (std::size_t i = 0; i < entries.size(); ++i) {
404 const auto& e = entries[i];
405 const int prio = e.priority + 1;
406
407 if constexpr (DirectoryStats::EnableInstrumentation) {
408 stats[i].mod = entries[i].modName.toStdString();
409 }
410
411 try {
412 if (e.stealFiles.length() > 0) {
413 stealModFilesIntoStructure(directoryStructure, e.modName, prio, e.absolutePath,
414 e.stealFiles);
415
416 if (progress) {
417 progress->addDone();
418 }
419 } else {
420 auto& mt = g_threads.request();
421
422 mt.gameFeatures = &m_Core.gameFeatures();
423 mt.progress = progress;
424 mt.ds = directoryStructure;
425 mt.modName = e.modName.toStdWString();
426 mt.path = QDir::toNativeSeparators(e.absolutePath).toStdWString();
427 mt.prio = prio;
428
429 mt.archives.clear();
430 for (auto&& a : e.archives) {
431 mt.archives.push_back(a.toStdWString());
432 }
433
434 mt.enabledArchives.clear();
435 for (auto&& a : m_EnabledArchives) {
436 mt.enabledArchives.insert(a.toStdWString());
437 }
438
439 mt.stats = &stats[i];
440
441 mt.wakeup();
442 }
443 } catch (const std::exception& ex) {
444 emit error(tr("failed to read mod (%1): %2").arg(e.modName, ex.what()));
445 }
446 }
447

Callers 1

Calls 11

dumpStatsFunction · 0.85
setMaxMethod · 0.80
addDoneMethod · 0.80
gameFeaturesMethod · 0.80
waitForAllMethod · 0.80
sizeMethod · 0.45
startMethod · 0.45
clearMethod · 0.45
insertMethod · 0.45
wakeupMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected