From: Anthony Geay Date: Fri, 3 Apr 2020 08:29:14 +0000 (+0200) Subject: attempt #2 X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=commitdiff_plain;h=009bbb825cbdbf304aa8bdf47f52b83413677c19 attempt #2 --- diff --git a/src/MEDWrapper/MED_Factory.cxx b/src/MEDWrapper/MED_Factory.cxx index 1973127fb..278838a0c 100644 --- a/src/MEDWrapper/MED_Factory.cxx +++ b/src/MEDWrapper/MED_Factory.cxx @@ -194,22 +194,16 @@ namespace MED remove(fileName.c_str()); isCreated = true; } - int minor = -1; + med_int wantedMajor = MED_MAJOR_NUM; + med_int wantedMinor = MED_MINOR_NUM; if (isCreated) { - med_int wantedMajor = MED_MAJOR_NUM; - med_int wantedMinor = MED_MINOR_NUM; if (theVersion > 0) { wantedMajor = theVersion/10; wantedMinor = theVersion%10; } - if (wantedMajor == MED_MAJOR_NUM) // the med file will be actually created - { - if (wantedMinor < MED_MINOR_NUM) - minor = wantedMinor; - } } - return new MED::TWrapper(fileName, true, minor); + return new MED::TWrapper(fileName, true, wantedMajor, wantedMinor); } } diff --git a/src/MEDWrapper/MED_Wrapper.cxx b/src/MEDWrapper/MED_Wrapper.cxx index 85a8d9f35..dc1e3f53f 100644 --- a/src/MEDWrapper/MED_Wrapper.cxx +++ b/src/MEDWrapper/MED_Wrapper.cxx @@ -78,13 +78,15 @@ namespace MED TFile(const TFile&); public: - TFile(const std::string& theFileName, TInt theMinor=-1): + TFile(const std::string& theFileName, TInt theMajor=-1, TInt theMinor=-1): myCount(0), myFid(0), myFileName(theFileName), + myMajor(theMajor), myMinor(theMinor) { - if ((myMinor < 0) || (myMinor > MED_MINOR_NUM)) myMinor = MED_MINOR_NUM; + if ((myMajor < 0) || (myMajor > MED_MAJOR_NUM)) myMajor = MED_MAJOR_NUM; + if ((myMinor < 0) || (myMajor == MED_MAJOR_NUM && myMinor > MED_MINOR_NUM)) myMinor = MED_MINOR_NUM; } ~TFile() @@ -98,7 +100,7 @@ namespace MED { if (myCount++ == 0) { const char* aFileName = myFileName.c_str(); - myFid = MEDfileVersionOpen(aFileName,med_access_mode(theMode), MED_MAJOR_NUM, myMinor, MED_RELEASE_NUM); + myFid = MEDfileVersionOpen(aFileName,med_access_mode(theMode), myMajor, myMinor, MED_RELEASE_NUM); } if (theErr) *theErr = TErr(myFid); @@ -125,6 +127,7 @@ namespace MED TInt myCount; TIdt myFid; std::string myFileName; + TInt myMajor; TInt myMinor; }; @@ -187,8 +190,9 @@ namespace MED //--------------------------------------------------------------- TWrapper - ::TWrapper(const std::string& theFileName, bool write, TInt theMinor): - myFile(new TFile(theFileName, theMinor)), + ::TWrapper(const std::string& theFileName, bool write, TInt theMajor, TInt theMinor): + myFile(new TFile(theFileName, theMajor, theMinor)), + myMajor(theMajor), myMinor(theMinor) { TErr aRet; diff --git a/src/MEDWrapper/MED_Wrapper.hxx b/src/MEDWrapper/MED_Wrapper.hxx index 6761a19e8..2d6a4ffca 100644 --- a/src/MEDWrapper/MED_Wrapper.hxx +++ b/src/MEDWrapper/MED_Wrapper.hxx @@ -52,7 +52,7 @@ namespace MED TWrapper& operator=(const TWrapper&); public: - TWrapper(const std::string& theFileName, bool write, TInt theVersion=-1); + TWrapper(const std::string& theFileName, bool write, TInt theMajor=-1, TInt theVersion=-1); virtual ~TWrapper(); @@ -939,6 +939,7 @@ namespace MED protected: PFile myFile; + TInt myMajor; TInt myMinor; };