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

Method collectFileListRecursively

launcher/MMCZip.cpp:404–436  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

402}
403
404bool MMCZip::collectFileListRecursively(const QString& rootDir, const QString& subDir, QFileInfoList *files,
405 MMCZip::FilterFunction excludeFilter) {
406 QDir rootDirectory(rootDir);
407 if (!rootDirectory.exists()) return false;
408
409 QDir directory;
410 if (subDir == nullptr)
411 directory = rootDirectory;
412 else
413 directory = QDir(subDir);
414
415 if (!directory.exists()) return false; // shouldn't ever happen
416
417 // recurse directories
418 QFileInfoList entries = directory.entryInfoList(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::Hidden);
419 for (const auto& e: entries) {
420 if (!collectFileListRecursively(rootDir, e.filePath(), files, excludeFilter))
421 return false;
422 }
423
424 // collect files
425 entries = directory.entryInfoList(QDir::Files);
426 for (const auto& e: entries) {
427 QString relativeFilePath = rootDirectory.relativeFilePath(e.absoluteFilePath());
428 if (excludeFilter && excludeFilter(relativeFilePath)) {
429 qDebug() << "Skipping file " << relativeFilePath;
430 continue;
431 }
432
433 files->append(e); // we want the original paths for MMCZip::compressDirFiles
434 }
435 return true;
436}

Callers

nothing calls this directly

Calls 4

existsMethod · 0.80
filePathMethod · 0.80
appendMethod · 0.80
QDirClass · 0.70

Tested by

no test coverage detected