f_utime

The f_utime function changes the timestamp of a file or directory.

FRESULT f_utime (
  const TCHAR* FileName,   /* Pointer to the file or directory path */
  const FILINFO* TimeDate  /* Time and data to be set */
);

Parameters

FileName
Pointer to the null-terminated string that specifies a file or directory to be changed.
TimeDate
Pointer to the file information structure that has a timestamp to be set in member fdate and ftime. Do not care any other members.

Return Values

FR_OK (0)
The function succeeded.
FR_NO_FILE
Could not find the file.
FR_NO_PATH
Could not find the path.
FR_INVALID_NAME
The file name is invalid.
FR_INVALID_DRIVE
The drive number is invalid.
FR_NOT_READY
The disk drive cannot work due to no medium in the drive or any other reason.
FR_WRITE_PROTECTED
The medium is write protected.
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_ENABLED
The logical drive has no work area.
FR_NO_FILESYSTEM
There is no valid FAT volume on the drive.

Description

The f_utime function changes the timestamp of a file or directory

Example

FRESULT set_timestamp (
    char *obj,     /* Pointer to the file name */
    int year,
    int month,
    int mday,
    int hour,
    int min,
    int sec
)
{
    FILINFO fno;

    fno.fdate = (WORD)(((year - 1980) * 512U) | month * 32U | mday);
    fno.ftime = (WORD)(hour * 2048U | min * 32U | sec / 2U);

    return f_utime(obj, &fno);
}

QuickInfo

Available when _FS_READONLY == 0 and _FS_MINIMIZE == 0.

See Also

f_stat, FILINFO

Return