User manual

Table Of Contents
380
mikoC PRO for PIC32
MikroElektronika
// Deletes a le. If le doesn’t exist, it will rst be created
// and then deleted.
void M_Delete_File() {
lename[7] = ‘F’;
Mmc_Fat_Assign(lename, 0);
Mmc_Fat_Delete();
}
// Tests whether le exists, and if so sends its creation date
// and le size via UART
void M_Test_File_Exist() {
unsigned long fsize;
unsigned int year;
unsigned short month, day, hour, minute;
unsigned char outstr[12];
Mmc_Fat_Get_File_Date(&year, &month, &day, &hour, &minute);
lename[7] = ‘B’; //uncomment this line to search for le that DOES exists
// lename[7] = ‘F’; //uncomment this line to search for le that DOES NOT exist
if (Mmc_Fat_Assign(lename, 0)) {
//--- le has been found - get its create date
Mmc_Fat_Get_File_Date(&year, &month, &day, &hour, &minute);
UART1_Write_Text(“ created: “);
WordToStr(year, outstr);
UART1_Write_Text(outstr);
ByteToStr(month, outstr);
UART1_Write_Text(outstr);
WordToStr(day, outstr);
UART1_Write_Text(outstr);
WordToStr(hour, outstr);
UART1_Write_Text(outstr);
WordToStr(minute, outstr);
UART1_Write_Text(outstr);
//--- le has been found - get its modied date
Mmc_Fat_Get_File_Date_Modied(&year, &month, &day, &hour, &minute);
UART1_Write_Text(“ modied: “);
WordToStr(year, outstr);
UART1_Write_Text(outstr);
ByteToStr(month, outstr);
UART1_Write_Text(outstr);
WordToStr(day, outstr);
UART1_Write_Text(outstr);
WordToStr(hour, outstr);
UART1_Write_Text(outstr);
WordToStr(minute, outstr);
UART1_Write_Text(outstr);
//--- get le size
fsize = Mmc_Fat_Get_File_Size();
LongToStr((signed long)fsize, outstr);
UART1_Write_Line(outstr);
}