From 3c6f5f8802dd300a48d390a7d08dad779565bf45 Mon Sep 17 00:00:00 2001 From: sECuRE Date: Tue, 23 Oct 2007 13:34:36 +0000 Subject: [PATCH] delete state/credits-file before saving, error-handling for logging git-svn-id: https://shell.noname-ev.de/svn/kasse/c128@51 af93e077-1a23-4f1e-9cbe-9382a9d578f5 --- config.c | 7 +++++++ kasse.c | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/config.c b/config.c index 5a70352..523e8e4 100644 --- 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 24b37dd..46d17bd 100644 --- 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); } -- 2.39.5