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:
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user