f_sync

The f_sync function flushes the cached information of a writing file.

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

Parameter

FileObject
Pointer to the open file object to be flushed.

Return Values

FR_OK, FR_DISK_ERR, FR_INT_ERR, FR_NOT_READY, FR_INVALID_OBJECT, FR_TIMEOUT

Description

The f_sync function performs the same process as f_close function but the file is left opened and can continue read/write/seek operations to the file. This is suitable for the applications that open files for a long time in write mode, such as data logger. Performing f_sync of periodic or immediataly after f_write can minimize the risk of data loss due to a sudden blackout or an unintentional media removal. However f_sync immediataly before f_close has no advantage because f_close performs f_sync in it. In other words, the differnce between those functions is that the file object is invalidated or not.

QuickInfo

Available when _FS_READONLY == 0.

See Also

f_close

Return