diff options
author | Nadia Holmquist Pedersen <nadia@nhp.sh> | 2020-05-06 03:49:20 +0200 |
---|---|---|
committer | Nadia Holmquist Pedersen <nadia@nhp.sh> | 2020-05-06 03:49:20 +0200 |
commit | beb3b20d5e85f9d58017684dc0abc39a0352f2f4 (patch) | |
tree | 7a055b9b35e09683bef1bd165ad9702e08d74955 /src | |
parent | 6cfe4faa56f4c7c34bf42cd600c66a2ed7966062 (diff) |
Fix crash with nonexistent config directory or writable files.
Diffstat (limited to 'src')
-rw-r--r-- | src/frontend/qt_sdl/Platform.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/frontend/qt_sdl/Platform.cpp b/src/frontend/qt_sdl/Platform.cpp index ddf48e9..7ce70ab 100644 --- a/src/frontend/qt_sdl/Platform.cpp +++ b/src/frontend/qt_sdl/Platform.cpp @@ -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 } |