f_utime

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

FRESULT f_utime (
  const TCHAR* path,  /* [IN] Object name */
  const FILINFO* fno  /* [IN] Time and date to be set */
);

Parameters

path
Pointer to the null-terminated string that specifies an object to be changed. If a null pointer is given, the function fails with FR_INVALID_DRIVE.
fno
Pointer to the file information structure that has new timestamps to be set in the members. fdate and ftime are for the last modified time. When FF_FS_CRTIME = 1, crdate and crtime for the created time are available in addition. Every timestamp is in local time. If fdate or crdate is invalid (0), the modified time or created time is left unchanged respectively. Do not care any other member.

Return Values

FR_OK, FR_DISK_ERR, FR_INT_ERR, FR_NOT_READY, FR_NO_FILE, FR_NO_PATH, FR_INVALID_NAME, FR_WRITE_PROTECTED, FR_INVALID_DRIVE, FR_NOT_ENABLED, FR_NO_FILESYSTEM, FR_TIMEOUT, FR_NOT_ENOUGH_CORE

Description

The f_utime function changes the timestamp of a file or sub-directory

Example

FRESULT set_timestamp (
    const char *fname,     /* 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);
#if FF_FS_CRTIME
    fno.crdate = 0;   /* Do not change created time in this code */
#endif
    return f_utime(fname, &fno);
}

QuickInfo

Available when FF_FS_READONLY == 0 and FF_USE_CHMOD == 1.

See Also

f_stat, FILINFO

Return