Correctly delete save files.

This commit is contained in:
Steve 2018-03-21 18:25:29 +00:00
parent 8339109f58
commit 726243fcfe
4 changed files with 6 additions and 3 deletions

View File

@ -502,10 +502,10 @@ void deleteSaveSlot(int slot)
sprintf(path, "%s/%d", app.saveDir, slot); sprintf(path, "%s/%d", app.saveDir, slot);
filenames = getFileList(path, &numFiles); filenames = getFileList(path, &numFiles);
for (i = 0 ; i < numFiles ; i++) for (i = 0 ; i < numFiles ; i++)
{ {
sprintf(path, "%s/%d/%s", app.saveDir, i, filenames[i]); sprintf(path, "%s/%d/%s", app.saveDir, slot, filenames[i]);
if (!deleteFile(path)) if (!deleteFile(path))
{ {

View File

@ -323,6 +323,8 @@ static void doOK(void)
saveSlot = game.saveSlot; saveSlot = game.saveSlot;
deleteSaveSlot(saveSlot);
stopMusic(); stopMusic();
newGame(); newGame();

View File

@ -53,6 +53,7 @@ extern void setSelectedWidget(char *name, char *group);
extern void showWidgetGroup(char *group); extern void showWidgetGroup(char *group);
extern void startSectionTransition(void); extern void startSectionTransition(void);
extern void stopMusic(void); extern void stopMusic(void);
extern void deleteSaveSlot(int slot);
extern App app; extern App app;
extern Colors colors; extern Colors colors;

View File

@ -197,7 +197,7 @@ char **getFileList(const char *dir, int *count)
int deleteFile(char *path) int deleteFile(char *path)
{ {
return unlink(path); return unlink(path) == 0;
} }
static int stringComparator(const void *a, const void *b) static int stringComparator(const void *a, const void *b)