aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNadia Holmquist Pedersen <nadia@nhp.sh>2020-06-03 14:41:07 +0200
committerNadia Holmquist Pedersen <nadia@nhp.sh>2020-06-03 14:41:07 +0200
commit7829070b7ff2bb86e2bc47065a57147757510b76 (patch)
treeffd37f91df02eb34bb069107409cf0b74981fd3f /src
parent6e0425d34e9bcdff5f93258e2127c95ebae0ea59 (diff)
Handle r+ file mode
Diffstat (limited to 'src')
-rw-r--r--src/frontend/qt_sdl/Platform.cpp40
1 files changed, 8 insertions, 32 deletions
diff --git a/src/frontend/qt_sdl/Platform.cpp b/src/frontend/qt_sdl/Platform.cpp
index 47befb0..e56e527 100644
--- a/src/frontend/qt_sdl/Platform.cpp
+++ b/src/frontend/qt_sdl/Platform.cpp
@@ -133,7 +133,14 @@ FILE* OpenFile(const char* path, const char* mode, bool mustexist)
return nullptr;
}
- QIODevice::OpenMode qmode = mode[0] == 'w' ? QIODevice::ReadWrite : QIODevice::ReadOnly;
+ QIODevice::OpenMode qmode;
+ if (strlen(mode) > 1 && mode[0] == 'r' && mode[1] == '+') {
+ qmode = QIODevice::OpenModeFlag::ReadWrite;
+ } else if (mode[0] == 'w') {
+ qmode = QIODevice::OpenModeFlag::Truncate;
+ } else {
+ qmode = QIODevice::OpenModeFlag::ReadOnly;
+ }
f.open(qmode);
FILE* file = fdopen(dup(f.handle()), mode);
@@ -167,37 +174,6 @@ FILE* OpenLocalFile(const char* path, const char* mode)
return OpenFile(fullpath.toUtf8(), mode, mode[0] != 'w');
}
-FILE* OpenDataFile(const char* path)
-{
-#ifdef PORTABLE
- return OpenLocalFile(path);
-#else
- QString melondir = "/melonDS/";
- QStringList sys_dirs = QStandardPaths::standardLocations(QStandardPaths::DataLocation);
- QString found = nullptr;
-
- for (int i = 0; i < sys_dirs.size(); i++)
- {
- QString f = sys_dirs.at(i) + melondir + path;
-
- if (QFile::exists(f))
- {
- found = f;
- break;
- }
- }
-
- if (found == nullptr)
- return nullptr;
-
- FILE* f = OpenFile(found.toUtf8(), "rb", false);
- if (f)
- return f;
-
- return nullptr;
-#endif
-}
-
void* Thread_Create(void (* func)())
{
QThread* t = QThread::create(func);