mirror of
https://github.com/OPM/ResInsight.git
synced 2026-09-03 20:53:13 -05:00
RegTestRunner : Add removeDirectoryAndFilesRecursively
This commit is contained in:
@@ -280,4 +280,39 @@ bool Utils::isStringMatch(const QString& filterString, const QString& value)
|
||||
return searcher.exactMatch(value);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool Utils::removeDirectoryAndFilesRecursively(const QString& dirName)
|
||||
{
|
||||
bool result = true;
|
||||
QDir dir(dirName);
|
||||
|
||||
if (dir.exists())
|
||||
{
|
||||
QFileInfoList fileInfoList =
|
||||
dir.entryInfoList(QDir::NoDotAndDotDot | QDir::System | QDir::Hidden | QDir::AllDirs | QDir::Files, QDir::DirsFirst);
|
||||
for (const auto& fileInfo : fileInfoList)
|
||||
{
|
||||
if (fileInfo.isDir())
|
||||
{
|
||||
result = removeDirectoryAndFilesRecursively(fileInfo.absoluteFilePath());
|
||||
}
|
||||
else
|
||||
{
|
||||
result = QFile::remove(fileInfo.absoluteFilePath());
|
||||
}
|
||||
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
result = QDir().rmdir(dirName);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace caf
|
||||
|
||||
@@ -69,6 +69,7 @@ public:
|
||||
static bool isFolderWritable(const QString& folderName);
|
||||
|
||||
static bool isStringMatch(const QString& filterString, const QString& value);
|
||||
static bool removeDirectoryAndFilesRecursively(const QString& dirName);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user