/* * Sample program for utime system call - No.30 * * utime, utimes - change access and/or modification times of an inode * * Synopsis * #include * #include * * int utime(const char *filename, sturct utimbuf *buf); * * #include * * int utimes(char *filename, sturct timeval *tvp); * * Description * utime changes the access and modification times of the * inode specified by filename to the actime and modtime * fields of buf respectively. If buf is NULL, then the * access and modification times of the file are set to the * current time. The utimbuf structure is: * * struct utimbuf { * time_t actime; * access time * * time_t modtime; * modification time * * }; */ #include #include #include #include main(int argc, char *argv[]) { time_t now; struct utimbuf tmbuf; if (argc != 2) exit(1); /* get timer and add 10 minutes */ time(&now); now += 600; /* set new timestamps */ tmbuf.actime = now; tmbuf.modtime = now; utime(argv[1], &tmbuf); exit(0); }