diff --git a/Fwk/AppFwk/CommonCode/cafUtils.cpp b/Fwk/AppFwk/CommonCode/cafUtils.cpp index f8fb68f254..679170b94b 100644 --- a/Fwk/AppFwk/CommonCode/cafUtils.cpp +++ b/Fwk/AppFwk/CommonCode/cafUtils.cpp @@ -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 diff --git a/Fwk/AppFwk/CommonCode/cafUtils.h b/Fwk/AppFwk/CommonCode/cafUtils.h index 8cbdde125c..cb92cee651 100644 --- a/Fwk/AppFwk/CommonCode/cafUtils.h +++ b/Fwk/AppFwk/CommonCode/cafUtils.h @@ -63,6 +63,8 @@ public: static QString indentString(int numSpacesToIndent, const QString& str); static bool getSaveDirectoryAndCheckOverwriteFiles(const QString& defaultDir, std::vector fileNames, QString* saveDir); + + static bool fileExists(const QString& fileName); }; }