Utils: Implement FilePath::removeRecursively

Sprinkle a few QTC_ASSERT to make sure we are in a known
context.

Cmake's FileApiReader uses this before moving directories
as QFile::rename does not do anything if the target exists.

Change-Id: I555f99e81a9fe7d93ae66145eeebfa9d5880bc51
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2021-06-28 15:26:44 +02:00
parent 5470385085
commit 5ead2afeeb
8 changed files with 47 additions and 2 deletions

View File

@@ -310,11 +310,11 @@ void FileApiReader::makeBackupConfiguration(bool store)
if (reply.exists()) {
if (replyPrev.exists())
FileUtils::removeRecursively(replyPrev);
replyPrev.removeRecursively();
QTC_CHECK(!replyPrev.exists());
if (!reply.renameFile(replyPrev))
Core::MessageManager::writeFlashing(tr("Failed to rename %1 to %2.")
.arg(reply.toString(), replyPrev.toString()));
}
FilePath cmakeCacheTxt = m_parameters.buildDirectory.pathAppended("CMakeCache.txt");