#1476 Add helper method fileExists() which includes isFile()

This commit is contained in:
Magne Sjaastad 2017-05-11 07:45:55 +02:00
parent 0472230523
commit e1e75a4fad
2 changed files with 20 additions and 0 deletions

View File

@ -223,4 +223,22 @@ bool Utils::getSaveDirectoryAndCheckOverwriteFiles(const QString& defaultDir, st
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool Utils::fileExists(const QString& fileName)
{
QFileInfo fi(fileName);
// QFileInfo::exists returns true for both files and folders
// Also check if the path points to a file
if (fi.exists() && fi.isFile())
{
return true;
}
return false;
}
} // namespace caf

View File

@ -63,6 +63,8 @@ public:
static QString indentString(int numSpacesToIndent, const QString& str);
static bool getSaveDirectoryAndCheckOverwriteFiles(const QString& defaultDir, std::vector<QString> fileNames, QString* saveDir);
static bool fileExists(const QString& fileName);
};
}