aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaklyy <102590697+Jaklyy@users.noreply.github.com>2024-02-13 14:17:29 -0500
committerGitHub <noreply@github.com>2024-02-13 20:17:29 +0100
commita8429af13150dcdb81fbb9aeb1b66b7c5ece582d (patch)
treeec1161b248f57e0def40701b9ea032990dbfa4b9
parent3415e23105cf92dd34e566fbb6215cc2abaaef18 (diff)
dont make a save file on launching a game (#1974)
avoids the issue of saves being created for roms that dont use save files.
-rw-r--r--src/frontend/qt_sdl/Platform.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/frontend/qt_sdl/Platform.cpp b/src/frontend/qt_sdl/Platform.cpp
index 9bb19d1..0cd4f61 100644
--- a/src/frontend/qt_sdl/Platform.cpp
+++ b/src/frontend/qt_sdl/Platform.cpp
@@ -31,6 +31,7 @@
#include <QMutex>
#include <QOpenGLContext>
#include <QSharedMemory>
+#include <QTemporaryFile>
#include <SDL_loadso.h>
#include "Platform.h"
@@ -333,13 +334,29 @@ bool LocalFileExists(const std::string& name)
bool CheckFileWritable(const std::string& filepath)
{
- FileHandle* file = Platform::OpenFile(filepath.c_str(), FileMode::Append);
+ FileHandle* file = Platform::OpenFile(filepath.c_str(), FileMode::Read);
+
if (file)
{
+ // if the file exists, check if it can be opened for writing.
Platform::CloseFile(file);
- return true;
+ file = Platform::OpenFile(filepath.c_str(), FileMode::Append);
+ if (file)
+ {
+ Platform::CloseFile(file);
+ return true;
+ }
+ else return false;
+ }
+ else
+ {
+ // if the file does not exist, create a temporary file to check, to avoid creating an empty file.
+ if (QTemporaryFile(filepath.c_str()).open())
+ {
+ return true;
+ }
+ else return false;
}
- else return false;
}
bool CheckLocalFileWritable(const std::string& name)