blob: 9f00ffcecd513431eb029a02d270277f9cc93275 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#include <stdio.h>
#include <sys/stat.h>
#define _POSIX_C_SOURCE 200809L
int main(int argc, char **argv)
{
if (argc != 3)
return 2;
struct stat f1;
if (stat(argv[1], &f1))
return 2;
struct stat f2;
if (stat(argv[2], &f2))
return 2;
printf("%s is ", argv[1]);
if (f2.st_mtime == f1.st_mtime)
{
if (f2.st_mtim.tv_nsec >= f1.st_mtim.tv_nsec)
printf("not ");
}
else if (f2.st_mtime > f1.st_mtime)
printf("not ");
printf("newer than %s\n", argv[2]);
return 0;
}
|