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>
This commit is contained in:
parent
71652ad4bf
commit
bb8d84c358
@ -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)
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user