1.2.7.4.36 SYS_FS_FileDirectoryTimeSet Function

C

SYS_FS_RESULT SYS_FS_FileDirectoryTimeSet
(
    const char* path,
    SYS_FS_TIME *time
);

Summary

Sets or changes the time for a file or directory.

Description

This function sets or change the time for a file or directory.

Precondition

The file/directory for which time is to be set must exist.

Parameters

ParamDescription
pathA path for the file/directory, for which the time is to be set.
ptrPointer to the structure of type SYS_FS_TIME, which contains the time data to be set.

Returns

SYS_FS_RES_SUCCESS - Set time operation was successful.

SYS_FS_RES_FAILURE - Set time operation was unsucessful. The reason for the failure can be retrieved with SYS_FS_Error.

Example

void setTime(void)
{
    SYS_FS_RESULT res;
    SYS_FS_TIME time;

    time.packedTime = 0;

    // All FAT FS times are calculated based on 0 = 1980
    time.discreteTime.year = (2021 - 1980); // Year is 2021
    time.discreteTime.month = 8; // Month (August)
    time.discreteTime.day = 9; // Day (9)
    time.discreteTime.hour = 15; // 3 PM
    time.discreteTime.minute = 06; // 06 minutes
    time.discreteTime.second = 00; // 00 seconds

    res = SYS_FS_FileDirectoryTimeSet("file.txt", &time);

    if( res != SYS_FS_RES_SUCCESS)
    {
        // time change has gone wrong
    }
}

Remarks

None.