Handle open flags more correctly

This commit is contained in:
Nadia Holmquist Pedersen 2020-06-03 16:41:34 +02:00
parent 23aeb5fb72
commit f9644abb67

View File

@ -137,9 +137,11 @@ FILE* OpenFile(const char* path, const char* mode, bool mustexist)
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;
qmode = QIODevice::OpenModeFlag::ReadWrite;
} else if (strlen(mode) > 1 && mode[0] == 'w' && mode[1] == '+') {
qmode = QIODevice::OpenModeFlag::Truncate | QIODevice::OpenModeFlag::ReadWrite;
} else if (mode[0] == 'w') {
qmode = QIODevice::OpenModeFlag::Truncate | QIODevice::OpenModeFlag::WriteOnly;
} else {
qmode = QIODevice::OpenModeFlag::ReadOnly;
}