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)
|
if (shouldMkdirFirst && QT_MKDIR(nativeName, 0777) == 0)
|
||||||
return true;
|
return true;
|
||||||
|
if (errno == EISDIR)
|
||||||
|
return true;
|
||||||
if (errno == EEXIST)
|
if (errno == EEXIST)
|
||||||
return isDir(nativeName);
|
return isDir(nativeName);
|
||||||
if (errno != ENOENT)
|
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().mkdir(dirName)); // calling mkdir on an existing dir will fail.
|
||||||
QVERIFY(QDir::current().mkpath(dirName)); // calling mkpath on an existing dir will pass
|
QVERIFY(QDir::current().mkpath(dirName)); // calling mkpath on an existing dir will pass
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
// the next line specifically targets Windows and macOS (QTBUG-85997, QTBUG-97110)
|
||||||
// the next line specifically targets Windows, see QTBUG-85997
|
// calling mkpath on an existing drive name (Windows) or root path (macOS) shall pass
|
||||||
QVERIFY(QDir().mkpath(QDir::rootPath())); // calling mkpath on an existing drive name will pass
|
QVERIFY(QDir().mkpath(QDir::rootPath()));
|
||||||
#endif
|
QVERIFY(!QDir().mkdir(QDir::rootPath()));
|
||||||
|
|
||||||
// Remove the directory and create a file with the same path
|
// Remove the directory and create a file with the same path
|
||||||
QDir::current().rmdir(dirName);
|
QDir::current().rmdir(dirName);
|
||||||
|
Loading…
Reference in New Issue
Block a user