From 986e732b806d7a877617bdde38996e4d98f1e54c Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Tue, 5 Sep 2023 15:20:31 +0200 Subject: [PATCH] Methods Plater::convert_gcode_to_binary() and Plater::convert_gcode_to_ascii() modified to change only extension in output file --- src/slic3r/GUI/Plater.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index f977833192..c60e58d47f 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -5487,7 +5487,12 @@ void Plater::convert_gcode_to_ascii() // Set out filename boost::filesystem::path path(into_u8(input_file)); - const std::string output_file = path.parent_path().string() + "/" + path.stem().string() + "_ascii" + path.extension().string(); + const std::string output_file = path.replace_extension("gcode").string(); + if (boost::filesystem::exists(output_file)) { + MessageDialog msg_dlg(this, GUI::format_wxstr(_L("File %1% already exists. Do you wish to overwrite it?"), output_file), _L("Notice"), wxYES_NO); + if (msg_dlg.ShowModal() != wxID_YES) + return; + } // Open destination file FilePtr out_file{ boost::nowide::fopen(output_file.c_str(), "wb") }; @@ -5533,7 +5538,12 @@ void Plater::convert_gcode_to_binary() // Set out filename boost::filesystem::path path(into_u8(input_file)); - const std::string output_file = path.parent_path().string() + "/" + path.stem().string() + "_binary" + path.extension().string(); + const std::string output_file = path.replace_extension("bgcode").string(); + if (boost::filesystem::exists(output_file)) { + MessageDialog msg_dlg(this, GUI::format_wxstr(_L("File %1% already exists. Do you wish to overwrite it?"), output_file), _L("Notice"), wxYES_NO); + if (msg_dlg.ShowModal() != wxID_YES) + return; + } // Open destination file FilePtr out_file{ boost::nowide::fopen(output_file.c_str(), "wb") };