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
This commit is contained in:
Vojtech Bubnik 2022-04-08 14:28:12 +02:00
parent 68b6672907
commit aef0c5a83c

View file

@ -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;