bfsWrite()
PROTOTYPE
#include <bfs.h>
int bfsWrite(const void *buf, unsigned int nbytes);
DESCRIPTION
bfsWrite() writes user data to the currently open file. buf points to a buffer containing the user data. Bytes are copied from buf to the file until nbytes bytes are written or an error occurs.
If any data is successfully written, bfsWrite() returns the number of bytes written. If no bytes were written, it sets errno and returns -1.
ERROR CODES
| EACCES | File is not open in update or write mode. |
| EFAULT | buf equals NULL. |
| other | An I/O error occurred while writing a flash page. |
EXAMPLE
/*-------------------------------------------------------------------*/
/* Write data to file. If wrote all, close (saving file) and return. */
/*-------------------------------------------------------------------*/
rc = bfsWrite((void *)TMP_BUF_BEG, len);
if (rc == len)
{
bfsClose();
printf("Wrote %d bytes to \"bfs/%s\"\n", len, name);
return;
}