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:
@@ -878,6 +878,24 @@ bool DockerDevice::removeFile(const FilePath &filePath) const
|
||||
return exitCode == 0;
|
||||
}
|
||||
|
||||
bool DockerDevice::removeRecursively(const FilePath &filePath) const
|
||||
{
|
||||
QTC_ASSERT(handlesFile(filePath), return false);
|
||||
QTC_ASSERT(filePath.path().startsWith('/'), return false);
|
||||
tryCreateLocalFileAccess();
|
||||
if (hasLocalFileAccess()) {
|
||||
const FilePath localAccess = mapToLocalAccess(filePath);
|
||||
const bool res = localAccess.removeRecursively();
|
||||
LOG("Remove recursively? " << filePath.toUserOutput() << localAccess.toUserOutput() << res);
|
||||
return res;
|
||||
}
|
||||
// Open this up only when really needed.
|
||||
// const CommandLine cmd("rm", "-rf", {filePath.path()});
|
||||
// const int exitCode = d->runSynchronously(cmd);
|
||||
// return exitCode == 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DockerDevice::copyFile(const FilePath &filePath, const FilePath &target) const
|
||||
{
|
||||
QTC_ASSERT(handlesFile(filePath), return false);
|
||||
|
||||
Reference in New Issue
Block a user