diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 150fb18527..054e9ed2fe 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -1123,6 +1123,8 @@ static bool createDirectoryWithParents(const QByteArray &nativeName, bool should if (shouldMkdirFirst && QT_MKDIR(nativeName, 0777) == 0) return true; + if (errno == EISDIR) + return true; if (errno == EEXIST) return isDir(nativeName); if (errno != ENOENT) diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index 7e77e22f67..8b6b390050 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -466,10 +466,10 @@ 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 + // the next line specifically targets Windows and macOS (QTBUG-85997, QTBUG-97110) + // calling mkpath on an existing drive name (Windows) or root path (macOS) shall pass + QVERIFY(QDir().mkpath(QDir::rootPath())); + QVERIFY(!QDir().mkdir(QDir::rootPath())); // Remove the directory and create a file with the same path QDir::current().rmdir(dirName);