00001 //------------------------------------------------------------------------------ 00002 // Headers 00003 //------------------------------------------------------------------------------ 00004 # include "FileIO.h" 00005 00006 00007 00008 //------------------------------------------------------------------------------ 00009 // Externals 00010 //------------------------------------------------------------------------------ 00011 00012 00013 //------------------------------------------------------------------------------ 00014 // Globals 00015 //------------------------------------------------------------------------------ 00016 00017 00018 //_______________________________________________________________________________ 00022 FileIO::FileIO() 00023 { 00024 initialiseFat(); 00025 } 00026 00027 00028 //_______________________________________________________________________________ 00032 FileIO::~FileIO() 00033 { 00034 } 00035 00036 00037 //_______________________________________________________________________________ 00043 bool FileIO::can_open_root_fs() 00044 { 00045 DIR_ITER *root = diropen("SD:/"); 00046 if (root) 00047 { 00048 dirclose(root); 00049 return true; 00050 } 00051 return false; 00052 } 00053 00054 00055 //_______________________________________________________________________________ 00056 /* 00057 * Initialise the FAT subsystem 00058 */ 00059 void FileIO::initialiseFat() 00060 { 00061 printf(" Initialising FAT ......... "); 00062 if (!fatInitDefault()) 00063 { 00064 //drawError(15,11,11,50,err1_initFatErr); 00065 printf("Unable to initialise FAT subsystem, exiting.\n"); 00066 sleep(2); 00067 exit(-1); 00068 } 00069 00070 //If you want to check the SD card. 00071 if (!can_open_root_fs()) 00072 { 00073 printf("Unable to open SD card, exiting.\n"); 00074 sleep(2); 00075 exit(-1); 00076 } 00077 printf("Done\n"); 00078 00079 } 00080