]> git.cameronkatri.com Git - bsdgames-darwin.git/commitdiff
Adventure(6) should check for errors (e.g. disk full or quota
authorhubertf <hubertf@NetBSD.org>
Sat, 17 Jul 1999 20:02:48 +0000 (20:02 +0000)
committerhubertf <hubertf@NetBSD.org>
Sat, 17 Jul 1999 20:02:48 +0000 (20:02 +0000)
exceeded) when writing out saved games. Do so!

Patch supplied by Joseph Myers <jsm28@cam.ac.uk> in PR 8016

adventure/save.c

index 9f0e8d3ac5eee1c8d5dcb760150a8a12bf0b1ff5..71b9e78f4092253ea345e0000e2eae99912187cc 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: save.c,v 1.6 1999/07/16 01:38:20 hubertf Exp $ */
+/*     $NetBSD: save.c,v 1.7 1999/07/17 20:02:48 hubertf Exp $ */
 
 /*-
  * Copyright (c) 1991, 1993
 
 /*-
  * Copyright (c) 1991, 1993
 #if 0
 static char sccsid[] = "@(#)save.c     8.1 (Berkeley) 5/31/93";
 #else
 #if 0
 static char sccsid[] = "@(#)save.c     8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: save.c,v 1.6 1999/07/16 01:38:20 hubertf Exp $");
+__RCSID("$NetBSD: save.c,v 1.7 1999/07/17 20:02:48 hubertf Exp $");
 #endif
 #endif                         /* not lint */
 
 #endif
 #endif                         /* not lint */
 
+#include <err.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include "hdr.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include "hdr.h"
@@ -152,7 +153,10 @@ save(outfile)                      /* Two passes on data: first to get checksum,
                        *s = (*s ^ random()) & 0xFF;    /* Lightly encrypt */
                fwrite(p->address, p->width, 1, out);
        }
                        *s = (*s ^ random()) & 0xFF;    /* Lightly encrypt */
                fwrite(p->address, p->width, 1, out);
        }
-       fclose(out);
+       if (fclose(out) != 0) {
+               warn("writing %s", outfile);
+               return 1;
+       }
        return 0;
 }
 
        return 0;
 }