From a73c504ea3d79a97777d870d341653e05f79a225 Mon Sep 17 00:00:00 2001 From: "lane.wei" Date: Tue, 18 Oct 2022 18:25:29 +0800 Subject: [PATCH] ENH: support sub-directories under system profiles when copy directory, will copy the sub-directory recursively Change-Id: Ib49cc38aaf889556b0b94f0e4d20451d3d4f03b2 --- src/slic3r/Utils/PresetUpdater.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/slic3r/Utils/PresetUpdater.cpp b/src/slic3r/Utils/PresetUpdater.cpp index 38734c508..d4eafae62 100644 --- a/src/slic3r/Utils/PresetUpdater.cpp +++ b/src/slic3r/Utils/PresetUpdater.cpp @@ -85,13 +85,19 @@ void copy_directory_fix(const fs::path &source, const fs::path &target) std::string name = dir_entry.path().filename().string(); std::string target_file = target.string() + "/" + name; - //CopyFileResult cfr = Slic3r::GUI::copy_file_gui(source_file, target_file, error_message, false); - CopyFileResult cfr = copy_file(source_file, target_file, error_message, false); - if (cfr != CopyFileResult::SUCCESS) { - BOOST_LOG_TRIVIAL(error) << "Copying failed(" << cfr << "): " << error_message; + if (boost::filesystem::is_directory(dir_entry)) { + const auto target_path = target / name; + copy_directory_fix(dir_entry, target_path); + } + else { + //CopyFileResult cfr = Slic3r::GUI::copy_file_gui(source_file, target_file, error_message, false); + CopyFileResult cfr = copy_file(source_file, target_file, error_message, false); + if (cfr != CopyFileResult::SUCCESS) { + BOOST_LOG_TRIVIAL(error) << "Copying failed(" << cfr << "): " << error_message; throw Slic3r::CriticalException(GUI::format( - _L("Copying directory %1% to %2% failed: %3%"), - source, target, error_message)); + _L("Copying directory %1% to %2% failed: %3%"), + source, target, error_message)); + } } } return;