|
|
1.1 ! root 1: #include <sys/types.h> ! 2: #include <sys/stat.h> ! 3: ! 4: /* ! 5: * newer x y ! 6: * ! 7: * returns 0 if x exists and y does not, or if ! 8: * files x and y both exist and x was modified ! 9: * at least as recently as y, and nonzero otherwise. ! 10: */ ! 11: ! 12: main (argc, argv) ! 13: int argc; ! 14: register int **argv; ! 15: { ! 16: struct stat x, y; ! 17: ! 18: /* insist on exactly two args */ ! 19: if (argc != 3) ! 20: return 1; ! 21: ! 22: /* does the first file exist? */ ! 23: if (stat (argv[1], &x) < 0) ! 24: return 1; ! 25: ! 26: /* does the second file exist? */ ! 27: if (stat (argv[2], &y) < 0) ! 28: return 0; ! 29: ! 30: /* fail if the first file is older than the second */ ! 31: if (x.st_mtime < y.st_mtime) ! 32: return 1; ! 33: ! 34: /* otherwise, succeed */ ! 35: return 0; ! 36: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.