From a9d64edd577e17f20f3c31c817a0871701338798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rnar=20Grip=20Fj=C3=A6r?= Date: Tue, 27 Jun 2017 14:49:33 +0200 Subject: [PATCH] #1643 Allow filename including extension for --case command line parameter --- ApplicationCode/Application/RiaApplication.cpp | 17 +++++++++++++---- Fwk/AppFwk/CommonCode/cafUtils.cpp | 10 ++++++++++ Fwk/AppFwk/CommonCode/cafUtils.h | 1 + 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 8b751e894a..b2a3b80c83 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -1478,18 +1478,27 @@ bool RiaApplication::parseArguments() QStringList caseNames = cvfqt::Utils::toQStringList(o.values()); foreach (QString caseName, caseNames) { - QString caseFileNameWithExt = caseName + ".EGRID"; - if (caf::Utils::fileExists(caseFileNameWithExt)) + QString fileExtension = caf::Utils::fileExtension(caseName); + if (caf::Utils::fileExists(caseName) && + (fileExtension == "EGRID" || fileExtension == "GRID")) { - openEclipseCaseFromFile(caseFileNameWithExt); + openEclipseCaseFromFile(caseName); } else { - caseFileNameWithExt = caseName + ".GRID"; + QString caseFileNameWithExt = caseName + ".EGRID"; if (caf::Utils::fileExists(caseFileNameWithExt)) { openEclipseCaseFromFile(caseFileNameWithExt); } + else + { + caseFileNameWithExt = caseName + ".GRID"; + if (caf::Utils::fileExists(caseFileNameWithExt)) + { + openEclipseCaseFromFile(caseFileNameWithExt); + } + } } } } diff --git a/Fwk/AppFwk/CommonCode/cafUtils.cpp b/Fwk/AppFwk/CommonCode/cafUtils.cpp index 679170b94b..31cb2f6cf0 100644 --- a/Fwk/AppFwk/CommonCode/cafUtils.cpp +++ b/Fwk/AppFwk/CommonCode/cafUtils.cpp @@ -241,4 +241,14 @@ bool Utils::fileExists(const QString& fileName) return false; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString Utils::fileExtension(const QString & fileName) +{ + QFileInfo fi(fileName); + + return fi.suffix(); +} + } // namespace caf diff --git a/Fwk/AppFwk/CommonCode/cafUtils.h b/Fwk/AppFwk/CommonCode/cafUtils.h index cb92cee651..dde22b2837 100644 --- a/Fwk/AppFwk/CommonCode/cafUtils.h +++ b/Fwk/AppFwk/CommonCode/cafUtils.h @@ -65,6 +65,7 @@ public: static bool getSaveDirectoryAndCheckOverwriteFiles(const QString& defaultDir, std::vector fileNames, QString* saveDir); static bool fileExists(const QString& fileName); + static QString fileExtension(const QString& fileName); }; }