Writes a null-terminated string to a file. If the file is type binary, the string is terminated in the file with a null. If the file is type text, the string is terminated with a newline. Parameters: buf - pointer to the string cfp = the CFILE pointer Returns the number of bytes written Throws an exception of type (cfile_error *) if the OS returns an error on write
| 765 | // Returns the number of bytes written |
| 766 | // Throws an exception of type (cfile_error *) if the OS returns an error on write |
| 767 | int cf_WriteString(CFILE *cfp, const char *buf) { |
| 768 | int len; |
| 769 | len = strlen(buf); |
| 770 | if (len != 0) // write string |
| 771 | cf_WriteBytes((uint8_t *)buf, len, cfp); |
| 772 | // Terminate with newline (text file) or NULL (binary file) |
| 773 | cf_WriteByte(cfp, (cfp->flags & CFF_TEXT) ? '\n' : 0); |
| 774 | return len + 1; |
| 775 | } |
| 776 | |
| 777 | // Just like stdio fprintf(), except works on a CFILE |
| 778 | int cfprintf(CFILE *cfp, const char *format, ...) { |
no test coverage detected