Report the system error of the G-code processor's writes too

The post-process and pre-heat passes of the G-code processor still
asked "Is the disk full?" only. Add the system error below, as the
G-code export does, and clear errno before each write and flush, so a
failure that sets no error code does not report an older one.
This commit is contained in:
Ian Bassi committed 2026-11-30 14:27:08 -03:00
1 parent 19982a5923
commit f1282048d2
2 files changed
+11 -1

No files matched your search

+3
View File
@@ -9181,6 +9181,8 @@ std::string GCode::GCodeOutputStream::last_error() const
void GCode::GCodeOutputStream::flush()
{
// Cleared first, so a failure that sets no error code does not report an older one.
errno = 0;
if (::fflush(this->f) != 0 && m_write_errno == 0)
m_write_errno = errno;
}
@@ -9199,6 +9201,7 @@ void GCode::GCodeOutputStream::write(const char *what)
const char* gcode = what;
// writes string to file
const size_t len = ::strlen(gcode);
errno = 0;
if (::fwrite(gcode, 1, len, this->f) != len && m_write_errno == 0)
m_write_errno = errno;
//FIXME don't allocate a string, maybe process a batch of lines?