Make QDir::mkpath() return true when given an existing drive name
Commit ed48391c592e8ba68c723e3017ac384f0c7a7c23 removed the check for ERROR_ACCESS_DENIED reported by the Windows CreateDirectory(...) function in case an existing windows drive name was passed as argument. This restores the behavior of the function which broke after 5.15. Pick-to: 6.2 Fixes: QTBUG-85997 Change-Id: Ie86188100766f7364acee57b15a250f4a2720b9f Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
This commit is contained in:
parent
57ec47921e
commit
71652ad4bf
@ -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);
|
||||
|
@ -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());
|
||||
|
Loading…
x
Reference in New Issue
Block a user