f_sync

The f_sync flushes the cached information of the wriiting file.

FRESULT f_sync (
  FIL* FileObject     // Pointer to the file object structure
);

Parameters

FileObject
Pointer to the file object to be flushed.

Return Values

FR_OK
The function succeeded.
FR_RW_ERROR
Any error occured in low level disk I/O.
FR_INCORRECT_DISK_CHANGE
Incorrect disk removal, such as a medium change during any file is opend, has been occured.
FR_NOT_ENABLED
FatFs module has not been enabled.

Description

The f_sync() writes back the cached information of the file being written. This performs the same function as f_close() but the file is left opened and can continue file read/write operations to the file. This is suitable for applications that open files for a long time in writing mode, such as data logger. Performing f_sync() of periodic or immediataly after f_write() can minimize risk of data loss due to sudden blackout or unintentional disk removal. This function is not supported in read-only configuration.

References

f_close

Return