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 .