From 2076898020d7247253aa4dbe5dd27c2fde9ce508 Mon Sep 17 00:00:00 2001 From: Misa Date: Sun, 26 Apr 2020 13:22:26 -0700 Subject: [PATCH] Fix deletequick() and deletetele() not deleting their files The problem here is that we're directly using the C stdio library, instead of using PHYSFS's stuff. So I've added a function FILESYSTEM_delete() that does exactly that. --- desktop_version/src/FileSystemUtils.cpp | 5 +++++ desktop_version/src/FileSystemUtils.h | 2 ++ desktop_version/src/Game.cpp | 8 ++++---- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/desktop_version/src/FileSystemUtils.cpp b/desktop_version/src/FileSystemUtils.cpp index ce4660af..728554c6 100644 --- a/desktop_version/src/FileSystemUtils.cpp +++ b/desktop_version/src/FileSystemUtils.cpp @@ -510,3 +510,8 @@ bool FILESYSTEM_openDirectory(const char *dname) return false; } #endif + +bool FILESYSTEM_delete(const char *name) +{ + return PHYSFS_delete(name) != 0; +} diff --git a/desktop_version/src/FileSystemUtils.h b/desktop_version/src/FileSystemUtils.h index ddf44d0d..718ecbea 100644 --- a/desktop_version/src/FileSystemUtils.h +++ b/desktop_version/src/FileSystemUtils.h @@ -23,4 +23,6 @@ std::vector FILESYSTEM_getLevelDirFileNames(); bool FILESYSTEM_openDirectoryEnabled(); bool FILESYSTEM_openDirectory(const char *dname); +bool FILESYSTEM_delete(const char *name); + #endif /* FILESYSTEMUTILS_H */ diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index dd9dab00..06f743bd 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -7188,16 +7188,16 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ ) void Game::deletequick() { - if( remove( "qsave.vvv" ) != 0 ) - puts("Error deleting qsave.vvv"); + if( !FILESYSTEM_delete( "saves/qsave.vvv" ) ) + puts("Error deleting saves/qsave.vvv"); else quicksummary = ""; } void Game::deletetele() { - if( remove( "tsave.vvv" ) != 0 ) - puts("Error deleting tsave.vvv"); + if( !FILESYSTEM_delete( "saves/tsave.vvv" ) ) + puts("Error deleting saves/tsave.vvv"); else telesummary = ""; }