MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / migrateConfig

Method migrateConfig

src/App/ApplicationDirectories.cpp:575–618  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

573}
574
575ApplicationDirectories::MigrationResult ApplicationDirectories::migrateConfig(
576 const fs::path& oldPath,
577 const fs::path& newPath)
578{
579 MigrationResult result;
580 fs::create_directories(newPath);
581 std::error_code errorCode;
582 for (auto& file : fs::directory_iterator(oldPath, errorCode)) {
583 if (file == newPath) {
584 // Handle the case where newPath is a subdirectory of oldPath
585 continue;
586 }
587 auto sourcePath = file.path();
588 auto pathString = Base::FileInfo::pathToString(sourcePath);
589
590 if (file.is_symlink(errorCode)) {
591 auto target = fs::read_symlink(sourcePath, errorCode);
592 if (errorCode || !fs::exists(target, errorCode)) {
593 Base::Console().warning("Migration: skipping broken symlink '%s'\n",
594 pathString.c_str());
595 result.failedPaths.push_back(sourcePath);
596 continue;
597 }
598 }
599
600 try {
601 fs::copy(sourcePath,
602 newPath / sourcePath.filename(),
603 fs::copy_options::recursive | fs::copy_options::copy_symlinks);
604 }
605 catch (const fs::filesystem_error& error) {
606 Base::Console().warning("Migration: failed to copy '%s': %s\n",
607 pathString.c_str(),
608 error.what());
609 result.failedPaths.push_back(sourcePath);
610 }
611 }
612 if (errorCode) {
613 Base::Console().warning("Migration: error iterating '%s': %s\n",
614 Base::FileInfo::pathToString(oldPath).c_str(),
615 errorCode.message().c_str());
616 }
617 return result;
618}
619
620ApplicationDirectories::MigrationResult ApplicationDirectories::migrateAllPaths(
621 const std::vector<fs::path>& paths) const

Callers

nothing calls this directly

Calls 8

pathMethod · 0.80
filenameMethod · 0.80
copyFunction · 0.70
warningMethod · 0.45
c_strMethod · 0.45
push_backMethod · 0.45
whatMethod · 0.45
messageMethod · 0.45

Tested by

no test coverage detected