#1643 Allow filename including extension for --case command line parameter

This commit is contained in:
Bjørnar Grip Fjær 2017-06-27 14:49:33 +02:00
parent 9f3dad9465
commit a9d64edd57
3 changed files with 24 additions and 4 deletions

View File

@ -1478,18 +1478,27 @@ bool RiaApplication::parseArguments()
QStringList caseNames = cvfqt::Utils::toQStringList(o.values()); QStringList caseNames = cvfqt::Utils::toQStringList(o.values());
foreach (QString caseName, caseNames) foreach (QString caseName, caseNames)
{ {
QString caseFileNameWithExt = caseName + ".EGRID"; QString fileExtension = caf::Utils::fileExtension(caseName);
if (caf::Utils::fileExists(caseFileNameWithExt)) if (caf::Utils::fileExists(caseName) &&
(fileExtension == "EGRID" || fileExtension == "GRID"))
{ {
openEclipseCaseFromFile(caseFileNameWithExt); openEclipseCaseFromFile(caseName);
} }
else else
{ {
caseFileNameWithExt = caseName + ".GRID"; QString caseFileNameWithExt = caseName + ".EGRID";
if (caf::Utils::fileExists(caseFileNameWithExt)) if (caf::Utils::fileExists(caseFileNameWithExt))
{ {
openEclipseCaseFromFile(caseFileNameWithExt); openEclipseCaseFromFile(caseFileNameWithExt);
} }
else
{
caseFileNameWithExt = caseName + ".GRID";
if (caf::Utils::fileExists(caseFileNameWithExt))
{
openEclipseCaseFromFile(caseFileNameWithExt);
}
}
} }
} }
} }

View File

@ -241,4 +241,14 @@ bool Utils::fileExists(const QString& fileName)
return false; return false;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString Utils::fileExtension(const QString & fileName)
{
QFileInfo fi(fileName);
return fi.suffix();
}
} // namespace caf } // namespace caf

View File

@ -65,6 +65,7 @@ public:
static bool getSaveDirectoryAndCheckOverwriteFiles(const QString& defaultDir, std::vector<QString> fileNames, QString* saveDir); static bool getSaveDirectoryAndCheckOverwriteFiles(const QString& defaultDir, std::vector<QString> fileNames, QString* saveDir);
static bool fileExists(const QString& fileName); static bool fileExists(const QString& fileName);
static QString fileExtension(const QString& fileName);
}; };
} }