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:
hjk
2021-06-29 09:41:53 +02:00
parent b058b6e841
commit 1e1c556bc8
7 changed files with 47 additions and 0 deletions

View File

@@ -898,6 +898,20 @@ bool FilePath::ensureWritableDir() const
return QDir().mkpath(m_data);
}
bool FilePath::ensureExistingFile() const
{
if (needsDevice()) {
QTC_ASSERT(s_deviceHooks.ensureExistingFile, return false);
return s_deviceHooks.ensureExistingFile(*this);
}
QFile f(m_data);
if (f.exists())
return true;
f.open(QFile::WriteOnly);
f.close();
return f.exists();
}
bool FilePath::isExecutableFile() const
{
if (needsDevice()) {