Utils: Implement FilePath::rename()

And uses it in CMake's fileapi reader.

Change-Id: I9e719aa4b253eaca17c6b304eab5e7268fcfab29
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
hjk
2021-06-28 13:57:10 +02:00
parent 782779f8f4
commit 54b4022987
8 changed files with 45 additions and 2 deletions

View File

@@ -887,6 +887,23 @@ bool DockerDevice::copyFile(const FilePath &filePath, const FilePath &target) co
return exitCode == 0;
}
bool DockerDevice::renameFile(const FilePath &filePath, const FilePath &target) const
{
QTC_ASSERT(handlesFile(filePath), return false);
QTC_ASSERT(handlesFile(target), return false);
tryCreateLocalFileAccess();
if (hasLocalFileAccess()) {
const FilePath localAccess = mapToLocalAccess(filePath);
const FilePath localTarget = mapToLocalAccess(target);
const bool res = localAccess.renameFile(localTarget);
LOG("Move " << filePath.toUserOutput() << localAccess.toUserOutput() << localTarget << res);
return res;
}
const CommandLine cmd("mv", {filePath.path(), target.path()});
const int exitCode = d->runSynchronously(cmd);
return exitCode == 0;
}
QDateTime DockerDevice::lastModified(const FilePath &filePath) const
{
QTC_ASSERT(handlesFile(filePath), return {});