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

Add a function to QFile that creates a file including any parent directories

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • None
    • Core: I/O
    • None

    Description

      QFile::open() with WriteOnly will create the file if it doesn't exist, but it won't create parent directories. QDir::mkpath() only works with directories.

      For example, it would be nice to be able to do this:

      QFile file("/tmp/this/will/be/created.txt");
      if (!file.createAndOpen(QIODevice::WriteOnly))
          // ...
      

      Or maybe add an overload of open that takes an enum to control the directory-creating behaviour:

      enum CreationPolicy {
          DoNotCreate,
          CreateFile,
          CreateParentDirectoriesAndFile
      }
      

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            mitch_curtis Mitch Curtis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes