diff --git a/src/libs/antares/study/header.cpp b/src/libs/antares/study/header.cpp index 4b751d75c7..029fd88742 100644 --- a/src/libs/antares/study/header.cpp +++ b/src/libs/antares/study/header.cpp @@ -166,26 +166,33 @@ bool StudyHeader::internalLoadFromINIFile(const IniFile& ini, bool warnings) } } + if (warnings) + { + logs.error() << "Study header: Invalid format"; + } + return false; +} + +bool StudyHeader::validateVersion() +{ if (version >= StudyVersion(7, 0)) { if (version > Data::StudyVersion::latest()) { - if (warnings) - { - logs.error() << "Header: This version is not supported (version found:" - << version.toString() - << ", expected: <=" << Data::StudyVersion::latest().toString() << ')'; - } + logs.error() << "Header: This version is not supported (version found:" + << version.toString() + << ", expected: <=" << Data::StudyVersion::latest().toString() << ')'; + return false; } - return true; } - - if (warnings) + else { - logs.error() << "Study header: Invalid format"; + logs.error() << "Version before 7.0 not supported, please upgrade"; + return false; } - return false; + + return true; } bool StudyHeader::loadFromFile(const AnyString& filename, bool warnings) diff --git a/src/libs/antares/study/include/antares/study/header.h b/src/libs/antares/study/include/antares/study/header.h index ec513143ec..aea7e0f35c 100644 --- a/src/libs/antares/study/include/antares/study/header.h +++ b/src/libs/antares/study/include/antares/study/header.h @@ -55,7 +55,6 @@ class StudyHeader final */ static bool readVersionFromFile(const std::filesystem::path& filename, std::string& version); -public: //! \name Constructor & Destructor //@{ /*! @@ -109,7 +108,8 @@ class StudyHeader final */ static StudyVersion tryToFindTheVersion(const std::string& folder); -public: + bool validateVersion(); + //! Caption of the study Yuni::String caption; diff --git a/src/libs/antares/study/load.cpp b/src/libs/antares/study/load.cpp index 00214717e8..b62872f350 100644 --- a/src/libs/antares/study/load.cpp +++ b/src/libs/antares/study/load.cpp @@ -47,6 +47,12 @@ bool Study::internalLoadHeader(const String& path) return false; } + if (!header.validateVersion()) + { + logs.error() << path << ": error with the version, aborting"; + return false; + } + // Informations about the study logs.info(); logs.notice() << "Preparing " << header.caption << "...";