MCPcopy Create free account
hub / github.com/Duet3D/RepRapFirmware / WriteBinaryToFile

Method WriteBinaryToFile

src/GCodes/GCodeBuffer/StringParser.cpp:1818–1847  ·  view source on GitHub ↗

Write a character to file, returning true if we finished doing the binary upload

Source from the content-addressed store, hash-verified

1816
1817// Write a character to file, returning true if we finished doing the binary upload
1818bool StringParser::WriteBinaryToFile(char b) noexcept
1819{
1820 if (b == eofString[eofStringCounter] && writingFileSize == 0)
1821 {
1822 eofStringCounter++;
1823 if (eofStringCounter < ARRAY_SIZE(eofString) - 1)
1824 {
1825 return false; // not reached end of input yet
1826 }
1827 }
1828 else
1829 {
1830 if (eofStringCounter != 0)
1831 {
1832 for (uint8_t i = 0; i < eofStringCounter; i++)
1833 {
1834 fileBeingWritten->Write(eofString[i]);
1835 }
1836 eofStringCounter = 0;
1837 }
1838 fileBeingWritten->Write(b); // writing one character at a time isn't very efficient, but uploading HTML files via USB is rarely done these days
1839 if (writingFileSize == 0 || fileBeingWritten->Length() < writingFileSize)
1840 {
1841 return false; // not reached end of input yet
1842 }
1843 }
1844
1845 FinishWritingBinary();
1846 return true;
1847}
1848
1849void StringParser::FinishWritingBinary() noexcept
1850{

Callers

nothing calls this directly

Calls 2

WriteMethod · 0.60
LengthMethod · 0.45

Tested by

no test coverage detected