O utime
/ utimes
syscall permite definir o acesso e tempo de modificação arbitrariamente. Assim, você pode stat
do arquivo e, em seguida, usar utime
para alterar apenas um deles. A partir da página de manual :
NAME
utime, utimes - change file last access and modification times
SINOPSE
#include <sys/types.h> #include <utime.h> int utime(const char *filename, const struct utimbuf *times); #include <sys/time.h> int utimes(const char *filename, const struct timeval times[2]);
DESCRIÇÃO
The utime() system call changes the access and modification times of the inode specified by filename to the actime and modtime fields of times respectively.
If times is NULL, then the access and modification times of the file are set to the current time.
Changing timestamps is permitted when: either the process has appropri‐ ate privileges, or the effective user ID equals the user ID of the file, or times is NULL and the process has write permission for the file.
[ … ]