utime() - set file times
#include <sys/types.h>
#include <utime.h>
int utime (const char *file, const struct utimbuf *timep)
The utime(2) function sets the access and modification times of the named file from the members of the timep argument.
If the times are specified (the timep argument is non-NULL) the caller must be the owner of the file.
If the times are not specified (the timep argument is NULL) the caller must be the owner of the file and have permission to write the file. In this case, the file times are set to the current time (now).
The timebuf structure timep is defined in <utime.h> and contains the following members:
time_t | actime | Access time |
time_t | modtime | Modification time |
Upon successful completion, 0 is returned. Otherwise, -1 is returned, errno is set to indicate the error, and the file times are not affected.
The utime(2) function may fail and set errno for any of these errors:
stat(2)