From aef0c5a83c6bdbdaa296426d0753494975ef9378 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Fri, 8 Apr 2022 14:28:12 +0200 Subject: [PATCH] Follow-up to 68b66729079bcf91ef44701c939f858f7ae9fe29 Fixed detection of config data at the end of gcode files G-code as config file was not imported correctly because end of windows stile end of lines (CRLF) were not processed correctly. See the file at #8172 --- src/libslic3r/Config.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/libslic3r/Config.cpp b/src/libslic3r/Config.cpp index 6f77c5f30e..e04dd9d7ec 100644 --- a/src/libslic3r/Config.cpp +++ b/src/libslic3r/Config.cpp @@ -822,12 +822,9 @@ public: return false; m_file_pos -= m_block_len; m_ifs.seekg(m_file_pos, m_ifs.beg); - m_ifs.read(m_block.data(), m_block_len); - if (!m_ifs.good()) { - if (!m_ifs.eof()) - return false; - m_block_len = m_ifs.gcount(); - } + if (! m_ifs.read(m_block.data(), m_block_len)) + return false; + assert(m_block_len == m_ifs.gcount()); } assert(m_block_len > 0); @@ -870,7 +867,7 @@ private: ConfigSubstitutions ConfigBase::load_from_gcode_file(const std::string &file, ForwardCompatibilitySubstitutionRule compatibility_rule) { // Read a 64k block from the end of the G-code. - boost::nowide::ifstream ifs(file); + boost::nowide::ifstream ifs(file, std::ifstream::binary); // Look for Slic3r or PrusaSlicer header. // Look for the header across the whole file as the G-code may have been extended at the start by a post-processing script or the user. bool has_delimiters = false;