FAT | RFS | XFS
utime()
PROTOTYPE
#include <posix.h>
int utime(const char *path, const struct utimbuf *times);
DESCRIPTION
utime() sets the data access and modification times of the file specified by path. Paths starting with ‘/’ are absolute. Otherwise they are relative to the CWD.
If times is NULL, the data access and modification times are set to the current time. Otherwise, they are set to the values in the utimbuf structure referenced by times. This structure is defined in “posix.h” and reproduced below:
struct utimbuf
{
time_t actime; /* last data access time (secs since Epoch) */
time_t modtime; /* last data modification time (secs since Epoch) */
};
The caller must either own the file or both have file write access and times equal to NULL. The file’s status change timestamp is set to the current time.
If successful, utime() returns 0. Otherwise, it sets errno and returns -1.
ERROR CODES
| EACCES | No execute access to directory in path prefix, caller is not file owner and doesn’t have write access. |
| EFAULT | path equals NULL. |
| ENAMETOOLONG | A name in path exceeds the effective maximum file name length. |
| ENOENT | path is the empty string or includes a file that was not found. |
| ENOTDIR | One of the non-leaf path components is not a directory. |
| EPERM | Caller is not file’s owner and times is not NULL. |
| EROFS | The volume is read only. |
EXAMPLE
utime("flash2/upgrade", NULL); // make access/modification times current