]> git.sur5r.net Git - c128-kasse/commitdiff
delete state/credits-file before saving, error-handling for logging
authorsECuRE <sECuRE@af93e077-1a23-4f1e-9cbe-9382a9d578f5>
Tue, 23 Oct 2007 13:34:36 +0000 (13:34 +0000)
committersECuRE <sECuRE@af93e077-1a23-4f1e-9cbe-9382a9d578f5>
Tue, 23 Oct 2007 13:34:36 +0000 (13:34 +0000)
git-svn-id: https://shell.noname-ev.de/svn/kasse/c128@51 af93e077-1a23-4f1e-9cbe-9382a9d578f5

config.c
kasse.c

index 5a70352e2925b5903c39bc278b36013cee786878..523e8e445d8c2b266ab2bae5c2ab6524cbb9ed4e 100644 (file)
--- a/config.c
+++ b/config.c
@@ -8,6 +8,9 @@
 #include "general.h"
 #include "config.h"
 
+/* undocumented function which scratches files */
+unsigned char __fastcall__ _sysremove(const char *name);
+
 unsigned long int money = 0;
 unsigned long int items_sold = 0;
 BYTE printer_port = 4;
@@ -49,11 +52,15 @@ void load_credits() {
 }
 
 void save_items() {
+       if (files_existing)
+               _sysremove("items");
        cbm_save("items", (BYTE)8, &status, sizeof(struct status_array_t));
        files_existing = true;
 }
 
 void save_credits() {
+       if (files_existing)
+               _sysremove("credits");
        cbm_save("credits", (BYTE)8, &credits, sizeof(struct credits_array_t));
        files_existing = true;
 }
diff --git a/kasse.c b/kasse.c
index 24b37dd20517907cc328c36317b8e0b1e76b7089..46d17bd2bba582071f97aa4c27cb8d6071dd176e 100644 (file)
--- a/kasse.c
+++ b/kasse.c
@@ -44,7 +44,13 @@ static void log_file(const char *s) {
                save_credits();
                exit(1);
        }
-       cbm_write((BYTE)8, s, strlen(s));
+       c = cbm_write((BYTE)8, s, strlen(s));
+       if (c != strlen(s)) {
+               cprintf("Could not save logfile, please make sure the floppy is not full!\n");
+               save_items();
+               save_credits();
+               exit(1);
+       }
        cbm_close((BYTE)8);
 }