Write a character to file, returning true if we finished doing the binary upload
| 1816 | |
| 1817 | // Write a character to file, returning true if we finished doing the binary upload |
| 1818 | bool 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 | |
| 1849 | void StringParser::FinishWritingBinary() noexcept |
| 1850 | { |