Only initially open files as writable if they actually should be.

This commit is contained in:
Nadia Holmquist Pedersen 2020-05-06 03:53:05 +02:00
parent beb3b20d5e
commit b746c0b727
1 changed files with 3 additions and 1 deletions

View File

@ -85,7 +85,9 @@ FILE* OpenFile(const char* path, const char* mode, bool mustexist)
return nullptr;
}
f.open(QIODevice::ReadWrite);
QIODevice::OpenMode qmode = mode[0] == 'w' ? QIODevice::ReadWrite : QIODevice::ReadOnly;
f.open(qmode);
FILE* file = fdopen(dup(f.handle()), mode);
f.close();