diff options
author | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-07-17 15:06:22 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-07-17 16:35:42 +0200 |
commit | b2603b76655ac819e43c063bb6f16bc95f358083 (patch) | |
tree | 0fbe2c367ebfffdb70e9e3f21a7cf408bafd9626 /src/corelib/io/qdir.cpp | |
parent | 99b94aadf875c822afb6c2580e43355ac392ac92 (diff) | |
parent | 756266d01560157b7274e466b9ffc1b0e2ef9a1f (diff) |
Merge remote-tracking branch 'origin/5.5' into HEAD
Conflicts:
src/plugins/platforms/windows/qwindowsopengltester.cpp
Change-Id: Ia7abeba9395ccf84e2fa81b91a5725a86dedb9fe
Diffstat (limited to 'src/corelib/io/qdir.cpp')
-rw-r--r-- | src/corelib/io/qdir.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 2ae865a534..e1d9858a66 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -1503,11 +1503,19 @@ bool QDir::removeRecursively() while (di.hasNext()) { di.next(); const QFileInfo& fi = di.fileInfo(); + const QString &filePath = di.filePath(); bool ok; - if (fi.isDir() && !fi.isSymLink()) - ok = QDir(di.filePath()).removeRecursively(); // recursive - else - ok = QFile::remove(di.filePath()); + if (fi.isDir() && !fi.isSymLink()) { + ok = QDir(filePath).removeRecursively(); // recursive + } else { + ok = QFile::remove(filePath); + if (!ok) { // Read-only files prevent directory deletion on Windows, retry with Write permission. + const QFile::Permissions permissions = QFile::permissions(filePath); + if (!(permissions & QFile::WriteUser)) + ok = QFile::setPermissions(filePath, permissions | QFile::WriteUser) + && QFile::remove(filePath); + } + } if (!ok) success = false; } |