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();