From f5375e656e1e2a0fb871240371f24dcdbc08f963 Mon Sep 17 00:00:00 2001 From: balika011 Date: Sun, 4 Apr 2021 18:47:26 +0200 Subject: [PATCH] check if there is already a backup --- main.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 8fb366f..30b5268 100644 --- a/main.c +++ b/main.c @@ -695,7 +695,36 @@ void drawLogo() char backupNVM() { - FILE *f = fopen("mass:/nvm.bin", "wb"); + FILE *f = fopen("mass:/nvm.bin", "rb"); + if (f) + { + fclose(f); + gsKit_clear(gsGlobal, Black); + + struct MENU menu; + menu.title = "An NVM backup found"; + menu.x_text = "X Select"; + menu.o_text = "O Exit"; + menu.option_count = 2; + + menu.options[0] = "Create a new backup"; + menu.options[1] = "Keep the current backup"; + + int selected = drawMenu(&menu); + + if (selected == -1) + { + ResetIOP(); + LoadExecPS2("rom0:OSDSYS", 0, NULL); + SleepThread(); + } + else if(selected == 1) + { + return 1; + } + } + + f = fopen("mass:/nvm.bin", "wb"); if (!f) { gsKit_clear(gsGlobal, Black);