forked from qt-creator/qt-creator
Utils: Add a FilePath::ensureExistingFile
Essentially a kind of 'touch', to be used in the CMake file API. Change-Id: Iaae62b441c0006b39d4bef5f06420e798c28c2a5 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -877,6 +877,22 @@ bool DockerDevice::exists(const FilePath &filePath) const
|
||||
return exitCode == 0;
|
||||
}
|
||||
|
||||
bool DockerDevice::ensureExistingFile(const FilePath &filePath) const
|
||||
{
|
||||
QTC_ASSERT(handlesFile(filePath), return false);
|
||||
tryCreateLocalFileAccess();
|
||||
if (hasLocalFileAccess()) {
|
||||
const FilePath localAccess = mapToLocalAccess(filePath);
|
||||
const bool res = localAccess.ensureExistingFile();
|
||||
LOG("Ensure existing file? " << filePath.toUserOutput() << localAccess.toUserOutput() << res);
|
||||
return res;
|
||||
}
|
||||
const QString path = filePath.path();
|
||||
const CommandLine cmd("touch", {path});
|
||||
const int exitCode = d->runSynchronously(cmd);
|
||||
return exitCode == 0;
|
||||
}
|
||||
|
||||
bool DockerDevice::removeFile(const FilePath &filePath) const
|
||||
{
|
||||
QTC_ASSERT(handlesFile(filePath), return false);
|
||||
|
||||
Reference in New Issue
Block a user