diff --git a/src/libslic3r/Utils.hpp b/src/libslic3r/Utils.hpp index 12d77c900..5ad565ae7 100644 --- a/src/libslic3r/Utils.hpp +++ b/src/libslic3r/Utils.hpp @@ -65,7 +65,7 @@ extern std::string normalize_utf8_nfc(const char *src); extern std::error_code rename_file(const std::string &from, const std::string &to); // Copy a file, adjust the access attributes, so that the target is writable. -extern int copy_file(const std::string &from, const std::string &to); +extern int copy_file(const std::string &from, const std::string &to, const bool with_check = false); // Compares two files, returns 0 if identical. extern int check_copy(const std::string& origin, const std::string& copy); diff --git a/src/libslic3r/utils.cpp b/src/libslic3r/utils.cpp index 47a32b4ba..33f85a3c2 100644 --- a/src/libslic3r/utils.cpp +++ b/src/libslic3r/utils.cpp @@ -417,7 +417,7 @@ std::error_code rename_file(const std::string &from, const std::string &to) #endif } -int copy_file(const std::string &from, const std::string &to) +int copy_file(const std::string &from, const std::string &to, const bool with_check) { const boost::filesystem::path source(from); const boost::filesystem::path target(to); @@ -436,8 +436,7 @@ int copy_file(const std::string &from, const std::string &to) return -1; } boost::filesystem::permissions(target, perms, ec); - return -1; - return check_copy(from, to); + return (with_check ? check_copy(from, to) : 0); } int check_copy(const std::string &origin, const std::string ©) diff --git a/src/slic3r/GUI/BackgroundSlicingProcess.cpp b/src/slic3r/GUI/BackgroundSlicingProcess.cpp index a8b88dd03..9d6a2a5ec 100644 --- a/src/slic3r/GUI/BackgroundSlicingProcess.cpp +++ b/src/slic3r/GUI/BackgroundSlicingProcess.cpp @@ -34,6 +34,7 @@ #include #include "I18N.hpp" #include "GUI.hpp" +#include "RemovableDriveManager.hpp" namespace Slic3r { @@ -107,7 +108,7 @@ void BackgroundSlicingProcess::process_fff() //FIXME localize the messages // Perform the final post-processing of the export path by applying the print statistics over the file name. std::string export_path = m_fff_print->print_statistics().finalize_output_path(m_export_path); - if (copy_file(m_temp_output_path, export_path) != 0) + if (copy_file(m_temp_output_path, export_path, GUI::RemovableDriveManager::get_instance().is_path_on_removable_drive(export_path)) != 0) throw std::runtime_error(_utf8(L("Copying of the temporary G-code to the output G-code failed. Maybe the SD card is write locked?"))); m_print->set_status(95, _utf8(L("Running post-processing scripts"))); run_post_process_scripts(export_path, m_fff_print->config());