MMC Library question

General discussion on mikroC PRO for PIC.
Post Reply
Author
Message
ISL_Dave
Posts: 695
Joined: 29 Jul 2009 09:48
Location: Sheffield

MMC Library question

#1 Post by ISL_Dave » 08 Mar 2010 18:07

Hi, I am wondering if it is possible to do the following.

I wish to write a line of text to the start of a new file so I need to check to see if the file exists and if not, create it and write the line. If the file exists, it should already have the line so I just need to append data.

I wonder if it is legal to Assign, get the filesize and then append as in the following example.
Mmc_Fat_Assign(&CurrentFile,0x80); //Find existing file or create a new one
Mmc_Fat_Reset(filesize); //Get the size of the file
if (filesize==0) Mmc_Fat_Write(Product, 32); //If the filesize is zero, the file has just been created
Mmc_Fat_Append();
Mmc_Fat_Set_File_Date(Bcd2Dec(year)+2000,Bcd2Dec(month),Bcd2Dec(date),Bcd2Dec(hours),Bcd2Dec(minutes),0);
Mmc_Fat_Write(Data, i); // write data to the assigned file or is there a better way to do it?

Post Reply

Return to “mikroC PRO for PIC General”