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 (0)
The function succeeded.
FR_DISK_ERR
The function failed due to an error in the disk function.
FR_INT_ERR
The function failed due to a wrong FAT structure or an internal error.
FR_NOT_READY
The disk drive cannot work due to no medium in the drive or any other reason.
FR_INVALID_OBJECT
The file object is invalid.

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 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 a sudden blackout or an unintentional disk removal. However f_sync immediataly before f_close has no advantage because f_close performs f_sync in it. This function is not available in read-only configuration.

References

f_close

Return