forked from qt-creator/qt-creator
Utils: Introduce FilePath::ensureWritableDir()
Combine the test and potential creation in one operation to potentially reduce the number of remote calls. Change-Id: I06ffa1256593afec430eb35605ba3b249f1da97c Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -793,6 +793,18 @@ bool FilePath::isWritableDir() const
|
||||
return exists() && fi.isDir() && fi.isWritable();
|
||||
}
|
||||
|
||||
bool FilePath::ensureWritableDir() const
|
||||
{
|
||||
if (needsDevice()) {
|
||||
QTC_ASSERT(s_deviceHooks.ensureWritableDir, return false);
|
||||
return s_deviceHooks.ensureWritableDir(*this);
|
||||
}
|
||||
const QFileInfo fi{m_data};
|
||||
if (exists() && fi.isDir() && fi.isWritable())
|
||||
return true;
|
||||
return QDir().mkpath(m_data);
|
||||
}
|
||||
|
||||
bool FilePath::isExecutableFile() const
|
||||
{
|
||||
if (needsDevice()) {
|
||||
|
||||
Reference in New Issue
Block a user