From 32d96798ccc49584823d17dfe3bec99f5f331601 Mon Sep 17 00:00:00 2001 From: elasota Date: Mon, 10 May 2021 19:43:52 -0400 Subject: [PATCH] Fix file deletion not working in web version --- AerofoilWeb/GpFileSystem_Web.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/AerofoilWeb/GpFileSystem_Web.cpp b/AerofoilWeb/GpFileSystem_Web.cpp index ef760f2..d956f08 100644 --- a/AerofoilWeb/GpFileSystem_Web.cpp +++ b/AerofoilWeb/GpFileSystem_Web.cpp @@ -431,22 +431,22 @@ bool GpFileSystem_Web::ResolvePath(PortabilityLayer::VirtualDirectory_t virtualD break; case PortabilityLayer::VirtualDirectories::kHighScores: pathAppend = "HighScores"; - rootPath = &m_basePath; + rootPath = &m_prefsPath; isIDB = true; break; case PortabilityLayer::VirtualDirectories::kUserData: pathAppend = "Houses"; - rootPath = &m_basePath; + rootPath = &m_prefsPath; isIDB = true; break; case PortabilityLayer::VirtualDirectories::kUserSaves: pathAppend = "SavedGames"; - rootPath = &m_basePath; + rootPath = &m_prefsPath; isIDB = true; break; case PortabilityLayer::VirtualDirectories::kPrefs: pathAppend = "Prefs"; - rootPath = &m_basePath; + rootPath = &m_prefsPath; isIDB = true; break; case PortabilityLayer::VirtualDirectories::kSourceExport: @@ -682,11 +682,12 @@ bool GpFileSystem_Web::DeleteFile(PortabilityLayer::VirtualDirectory_t virtualDi if (unlink(resolvedPath.c_str()) < 0) { existed = (errno != ENOENT); - if (existed && isIDB) - FlushFileSystem(); - return false; } + + if (isIDB) + MarkFSStateDirty(); + existed = true; return true; } @@ -854,7 +855,11 @@ void GpIOStream::Close() bool IGpFileSystem::DeleteFile(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, bool &existed) { - return static_cast(this)->DeleteFile(virtualDirectory, path, existed); + bool deleted = static_cast(this)->DeleteFile(virtualDirectory, path, existed); + if (deleted) + GpFileSystem_Web::FlushFS(); + + return deleted; } #endif