diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index d1a197698e5..9e009a05e7d 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -1180,7 +1180,7 @@ bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool crea // mkpath should return true, if the directory already exists, mkdir false. if (!createParents) return false; - if (lastError == ERROR_ALREADY_EXISTS) + if (lastError == ERROR_ALREADY_EXISTS || lastError == ERROR_ACCESS_DENIED) return isDirPath(dirName, nullptr); return createDirectoryWithParents(dirName, false); diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index 3675e45f838..7e77e22f67e 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -466,6 +466,11 @@ void tst_QDir::makedirReturnCode() QVERIFY(!QDir::current().mkdir(dirName)); // calling mkdir on an existing dir will fail. QVERIFY(QDir::current().mkpath(dirName)); // calling mkpath on an existing dir will pass +#ifdef Q_OS_WIN + // the next line specifically targets Windows, see QTBUG-85997 + QVERIFY(QDir().mkpath(QDir::rootPath())); // calling mkpath on an existing drive name will pass +#endif + // Remove the directory and create a file with the same path QDir::current().rmdir(dirName); QVERIFY(!f.exists());