| 400 | } |
| 401 | |
| 402 | bool 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 | } |
no test coverage detected