forked from qt-creator/qt-creator
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:
@@ -84,6 +84,7 @@ static DeviceFileHooks s_deviceHooks;
|
||||
*/
|
||||
bool FileUtils::removeRecursively(const FilePath &filePath, QString *error)
|
||||
{
|
||||
QTC_ASSERT(!filePath.needsDevice(), return false);
|
||||
QFileInfo fileInfo = filePath.toFileInfo();
|
||||
if (!fileInfo.exists() && !fileInfo.isSymLink())
|
||||
return true;
|
||||
@@ -1406,6 +1407,15 @@ bool FilePath::removeFile() const
|
||||
return QFile::remove(path());
|
||||
}
|
||||
|
||||
bool FilePath::removeRecursively() const
|
||||
{
|
||||
if (needsDevice()) {
|
||||
QTC_ASSERT(s_deviceHooks.removeRecursively, return false);
|
||||
return s_deviceHooks.removeRecursively(*this);
|
||||
}
|
||||
return FileUtils::removeRecursively(*this);
|
||||
}
|
||||
|
||||
bool FilePath::copyFile(const FilePath &target) const
|
||||
{
|
||||
if (needsDevice()) {
|
||||
|
||||
Reference in New Issue
Block a user