mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-23 14:19:55 -06:00
Fix crash with nonexistent config directory or writable files.
This commit is contained in:
@ -80,10 +80,12 @@ FILE* OpenFile(const char* path, const char* mode, bool mustexist)
|
||||
{
|
||||
QFile f(path);
|
||||
|
||||
if (!mustexist && !f.exists())
|
||||
if (mustexist && !f.exists())
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
f.open(QIODevice::ReadOnly);
|
||||
f.open(QIODevice::ReadWrite);
|
||||
FILE* file = fdopen(dup(f.handle()), mode);
|
||||
f.close();
|
||||
|
||||
@ -105,7 +107,9 @@ FILE* OpenLocalFile(const char* path, const char* mode)
|
||||
fullpath = QString("./") + path;
|
||||
#else
|
||||
// Check user configuration directory
|
||||
fullpath = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/melonDS/";
|
||||
QDir config(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation));
|
||||
config.mkdir("melonDS");
|
||||
fullpath = config.absolutePath() + "/melonDS/";
|
||||
fullpath.append(path);
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user