Summary Files Commits Branches @commit @diff @stats
path: root / Year 3 / System programming / Practice03 / ex3.c
blob: 45019bd6ee1b2a0194c81448bba85e8764e52b71 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <sys/stat.h>
#include <utime.h> // struct utimbuf, utime
#include <stdio.h> // perror

int main(int argc, char* argv[]) {
	struct stat buf;
	if(stat(argv[1], &buf) < 0) {
		perror("stat");
		return 1;
	}

	struct utimbuf newtime = { buf.st_atime - 60 * 60 * 1, buf.st_mtime + 60 * 1 };
	if (utime(argv[1], &newtime) < 0) {
		perror("utime");
		return 2;
	}
}