29#include <sys/unistd.h>
39 printf(
"\n\nFile I/O Example (Built " __DATE__
" " __TIME__
")\n\n");
43 int fd = open(
"test.txt", O_RDONLY);
50 printf(
"File test.txt not found, creating...");
51 fd = open(
"test.txt", O_RDWR | O_CREAT, 0644);
54 char message[] =
"G'day World!\n";
55 int count = write(fd, message,
sizeof(message));
59 printf(
"%d bytes written!\n"
60 "Run application again to see what was written.\n",
65 printf(
"Error %d!\n Failed to write to file!\n", errno);
75 printf(
"File I/O is currently not supported on this platform!\n");
82 int count = read(fd, buffer,
sizeof(buffer) - 1);
88 printf(
"%d bytes read!\nContents: %s\n", count, buffer);
92 printf(
"Error %d!\nFailed to read from file!\n", errno);
void app_init(void)
Main entry point to the application.