Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-57023

QFile::open should return false when creating a file with invalid file name on Windows

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Invalid
    • Affects Version/s: 5.7.0
    • Fix Version/s: 5.9.0
    • Component/s: Core: I/O
    • Labels:
      None
    • Environment:
      Windows 10 64 bit, MSVC2013.
    • Commits:
      346cd79192ef71afa572812e17f1d422594651a0

      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

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            jefernan Jesus Fernandez
            Reporter:
            kuszko kuszko
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes