summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarsten Heimrich <karsten.heimrich@qt.io>2021-10-15 13:32:20 +0200
committerKarsten Heimrich <karsten.heimrich@qt.io>2021-10-20 15:04:51 +0000
commitbb8d84c358eb4b324258b936bdeb211fdd90d7cd (patch)
tree8f331db097ff4c2af0c7250b9fa8a1322cc47f65
parent71652ad4bf7b4cfe35473c3f93213c16e7653135 (diff)
Make QDir::mkpath() return true when given an existing root path
On macOs with APFS mkdir sets errno to EISDIR, so take the error code into account. Pick-to: 6.2 Fixes: QTBUG-97110 Change-Id: I8e7d10c95430a2802bdbfbf94dd65219bd9071a7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp2
-rw-r--r--tests/auto/corelib/io/qdir/tst_qdir.cpp8
2 files changed, 6 insertions, 4 deletions
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);