Details
Description
On Windows, calling QFile::open after constructing a QFile using an invalid file name as path, generates an empty file with a truncated name, and no error is returned on open(). For example: calling QFile::open on testLog-03:20.803Z.txt results in the creation of the file testLog-03 and no content is written with write().
Complete code below:
#include <QFile>
#include <stdio.h>
int main()
{
QString filename = "testLog-03:20.803Z.txt";
QFile file(filename);
printf("Trying to create file %s\n", filename.toStdString().c_str());
printf("QFile.fileName: %s\n", file.fileName().toStdString().c_str());
if (!file.open(QFile::WriteOnly | QFile::Append))
{ printf("Failed!"); return -1; }printf("Succeded!\n");
return 0;
}
Used MSVC2013 .
Attachments
For Gerrit Dashboard: QTBUG-57023 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
176309,15 | Make QFile::open fail when using an invalid file name | 5.9 | qt/qtbase | Status: MERGED | +2 | 0 |
200923,2 | Revert "Make QFile::open fail when using an invalid file name" | 5.9 | qt/qtbase | Status: MERGED | +2 | 0 |