From 3421298e040728675198d280425ba99395ca9641 Mon Sep 17 00:00:00 2001 From: vsr Date: Thu, 28 Mar 2019 14:54:46 +0300 Subject: [PATCH] Issue !16751: [CEA16749] import MED 3.0 files in SMESH: exception --- src/MEDWrapper/MED_Factory.cxx | 4 ++-- src/MEDWrapper/MED_Wrapper.cxx | 21 +++++++++------------ src/MEDWrapper/MED_Wrapper.hxx | 2 +- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/MEDWrapper/MED_Factory.cxx b/src/MEDWrapper/MED_Factory.cxx index 12c0f597a..c6d62d253 100644 --- a/src/MEDWrapper/MED_Factory.cxx +++ b/src/MEDWrapper/MED_Factory.cxx @@ -211,7 +211,7 @@ namespace MED if (!CheckCompatibility(fileName)) { EXCEPTION(std::runtime_error, "Cannot open file '"<Open(eLECTURE_ECRITURE, &aRet); - // if (aRet < 0) - // myFile->Close(); - // myFile->Open(eLECTURE_AJOUT, &aRet); - // } - if (aRet < 0) { - myFile->Close(); - myFile->Open(eLECTURE, &aRet); + if ( write ) { + myFile->Open(eLECTURE_ECRITURE, &aRet); + if (aRet < 0) { + myFile->Close(); + myFile->Open(eCREATION, &aRet); + } } - if (aRet < 0) { - myFile->Close(); - myFile->Open(eCREATION, &aRet); + else { + myFile->Open(eLECTURE, &aRet); } } diff --git a/src/MEDWrapper/MED_Wrapper.hxx b/src/MEDWrapper/MED_Wrapper.hxx index 7acbf4ce0..e236f206c 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, TInt theVersion=-1); + TWrapper(const std::string& theFileName, bool write, TInt theVersion=-1); virtual ~TWrapper(); -- 2.39.2