Writes the specified number of bytes from a file into the buffer DO NOT USE THIS TO WRITE STRUCTURES. This function is for byte data, such as a string or a bitmap of 8-bit pixels. Returns the number of bytes written. Throws an exception of type (cfile_error *) if the OS returns an error on write
| 747 | // Returns the number of bytes written. |
| 748 | // Throws an exception of type (cfile_error *) if the OS returns an error on write |
| 749 | int cf_WriteBytes(const uint8_t *buf, int count, CFILE *cfp) { |
| 750 | int i; |
| 751 | if (!(cfp->flags & CFF_WRITING)) |
| 752 | return 0; |
| 753 | ASSERT(count > 0); |
| 754 | i = fwrite(buf, 1, count, cfp->file); |
| 755 | cfp->position += i; |
| 756 | if (i != count) |
| 757 | ThrowCFileError(CFE_WRITING, cfp, strerror(errno)); |
| 758 | return i; |
| 759 | } |
| 760 | // Writes a null-terminated string to a file. If the file is type binary, |
| 761 | // the string is terminated in the file with a null. If the file is type |
| 762 | // text, the string is terminated with a newline. |
no test coverage detected