From: Edward Wang Date: Sat, 29 Oct 1983 13:14:16 +0000 (-0800) Subject: remove old tmp files X-Git-Tag: BSD-4_3-Snapshot-Development~10946 X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/commitdiff_plain/30d1a80b121612883a3367b8334b927f2a91cef8?hp=3ee7f12c9e68ca7678a98a3e03f6b30b49d76319 remove old tmp files SCCS-vsn: games/sail/sync.c 1.6 --- diff --git a/usr/src/games/sail/sync.c b/usr/src/games/sail/sync.c index 5215b512fa..251c8ae96e 100644 --- a/usr/src/games/sail/sync.c +++ b/usr/src/games/sail/sync.c @@ -1,5 +1,5 @@ #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" @@ -30,12 +30,23 @@ register struct ship *ship; Write(W_SIGNAL, from, 1, (int)message, 0, 0, 0); } +#include +#include sync_exists(game) { char buf[sizeof sync_file]; + struct stat s; + time_t t; (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()