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

Function mergeFolders

launcher/FileSystem.cpp:402–425  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

400}
401
402bool mergeFolders(QString dstpath, QString srcpath)
403{
404 std::error_code ec;
405 fs::path fullSrcPath = srcpath.toStdString();
406 fs::path fullDstPath = dstpath.toStdString();
407 for (auto& entry : fs::recursive_directory_iterator(fullSrcPath))
408 {
409 fs::path relativeChild = fs::relative(entry, fullSrcPath);
410 if (entry.is_directory())
411 if (!fs::exists(fullDstPath / relativeChild))
412 fs::create_directory(fullDstPath / relativeChild);
413 if (entry.is_regular_file())
414 {
415 fs::path childDst = fullDstPath / relativeChild;
416 if (fs::exists(childDst))
417 fs::remove(childDst);
418 fs::copy(entry, childDst, fs::copy_options::none, ec);
419 if (ec.value() != 0)
420 qCritical() << QString("File copy failed with: %1. File was %2 -> %3").arg(QString::fromStdString(ec.message()), entry.path().c_str(), childDst.c_str());
421 }
422 }
423
424 return ec.value() == 0;
425}
426
427}

Callers 2

commitStagedInstanceMethod · 0.85
createInstanceMethod · 0.85

Calls 3

copyClass · 0.85
QStringClass · 0.85
pathMethod · 0.80

Tested by

no test coverage detected