Skip to content

Commit

Permalink
dont make a save file on launching a game (melonDS-emu#1974)
Browse files Browse the repository at this point in the history
avoids the issue of saves being created for roms that dont use save files.
  • Loading branch information
Jaklyy authored Feb 13, 2024
1 parent 3415e23 commit a8429af
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/frontend/qt_sdl/Platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <QMutex>
#include <QOpenGLContext>
#include <QSharedMemory>
#include <QTemporaryFile>
#include <SDL_loadso.h>

#include "Platform.h"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit a8429af

Please sign in to comment.