The system_fwrite_atomic function writes a specified number of bytes from a specified buffer into a specified file. The function also locks the file prior to performing the write, and then unlocks it when done. This process avoids interference between simultaneous write actions. Before system_fwrite_atomic can be used, you must open the file using any of the system_fopen functions except system_fopenRO.
int system_fwrite_atomic(SYS_FILE fd, char *buf, int sz);
Returns IO_OKAY if the write/lock succeeded, or IO_ERROR if the write/lock failed.
SYS_FILE fd is the platform-independent file descriptor.
char *buf is the buffer containing the bytes to be written.
int sz is the number of bytes to write to the file.
SYS_FILE logfd;char *logmsg = "An error occurred."; system_fwrite_atomic(logfd, logmsg, strlen(logmsg));
system_errmsg, system_fopenRO, system_fopenRW, system_fopenWA, system_lseek, system_fread, system_fwrite, system_flock, system_ulock, system_fclose