You are currently viewing the documentation for:
ECF_Flush
ECF_Flush writes all unsaved data in the sector cache to the block device.
ECF_ErrorCode ECF_Flush(
   char driveLetter
);
Parameters
driveLetter
This is the drive letter you want to use to refer to this file system. E.g. 'A'.
Return value
Returns one of the EcFAT error codes (ECFERR_SUCCESS on success)
Remarks
Some systems that can experience sudden power loss can benefit from calling ECF_Flush when it wants to make sure that all data has been written to the block device. After a successful call to ECF_Flush the data is guaranteed to be written to the block device. If you expect a power loss, you should also enable journaling (see ECF_Mount) to make sure that writes will not corrupt the file system.
Example Code
#include <EcFAT/EcFAT.h>

void WriteToLogFile(struct ECF_FileHandle *pFileHandle, const char *logEntry)
{
   // Error checking omitted

   ECF_WriteFile(pFileHandle, strlen(logEntry), logEntry);
   
   // Make sure the log entry is actually written to disk.
   // We assume that the file is located on drive 'A'. 
   ECF_Flush('A');
}
See also