ex_file_read.c

This example code will read a file from the File System.

00001 included "fsee.h"
00002 
00008 void test(void) {
00009     FILE f;
00010     BYTE c;
00011 
00012     f = fileOpen("filename.txt", 0);   //Open the given file
00013 
00014     if (f == FILE_INVALID )
00015     {
00016         //File not found, take action
00017     }
00018     else if ( f == FSYS_NOT_AVAILABLE )
00019     {
00020         //File System not available
00021     }
00022     else
00023     {
00024         while (1) {
00025             //Check if file has reached end
00026             if ( fileIsEOF(f) ) {
00027                 fileClose(f);
00028                 
00029                 //End of file, take whatever action is required ................
00030                 break;
00031             }
00032             
00033             //Read byte from file
00034             c = fileGetByte(f);
00035 
00036             //Check if error occured
00037             if ( fileHasError(f) ) {
00038                 fileClose(f);
00039                 
00040                 //Take action.............
00041                 break;
00042             }
00043         }
00044     }
00045 }

Generated on Thu Sep 21 20:31:01 2006 for SBC65EC Web Server by  doxygen 1.4.7