remove old tmp files
authorEdward Wang <edward@ucbvax.Berkeley.EDU>
Sat, 29 Oct 1983 13:14:16 +0000 (05:14 -0800)
committerEdward Wang <edward@ucbvax.Berkeley.EDU>
Sat, 29 Oct 1983 13:14:16 +0000 (05:14 -0800)
SCCS-vsn: games/sail/sync.c 1.6

usr/src/games/sail/sync.c

index 5215b51..251c8ae 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)sync.c      1.5 83/10/28";
+static char *sccsid = "@(#)sync.c      1.6 83/10/28";
 #endif
 
 #include "externs.h"
 #endif
 
 #include "externs.h"
@@ -30,12 +30,23 @@ register struct ship *ship;
        Write(W_SIGNAL, from, 1, (int)message, 0, 0, 0);
 }
 
        Write(W_SIGNAL, from, 1, (int)message, 0, 0, 0);
 }
 
+#include <sys/types.h>
+#include <sys/stat.h>
 sync_exists(game)
 {
        char buf[sizeof sync_file];
 sync_exists(game)
 {
        char buf[sizeof sync_file];
+       struct stat s;
+       time_t t;
 
        (void) sprintf(buf, SF, game);
 
        (void) sprintf(buf, SF, game);
-       return access(buf, 0) >= 0;
+       time(&t);
+       if (stat(buf, &s) < 0)
+               return 0;
+       if (s.st_mtime < t - 60*60*2) {         /* 2 hours */
+               unlink(buf);
+               return 0;
+       } else
+               return 1;
 }
 
 sync_open()
 }
 
 sync_open()