X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDWrapper%2FMED_Factory.cxx;h=51fe44ce3f79263b688e5b8713381086a9ccebde;hb=e330934ca6f8bb1f67b5367bb65a861868998aeb;hp=02b7e866ee737e69f6029ec33970789626113043;hpb=b7a7d49664daa32e1befb558280e13ed0bde37c9;p=modules%2Fsmesh.git diff --git a/src/MEDWrapper/MED_Factory.cxx b/src/MEDWrapper/MED_Factory.cxx index 02b7e866e..51fe44ce3 100644 --- a/src/MEDWrapper/MED_Factory.cxx +++ b/src/MEDWrapper/MED_Factory.cxx @@ -35,6 +35,7 @@ extern "C" #include #endif } +#include namespace MED { @@ -47,22 +48,24 @@ namespace MED #endif } - bool CheckCompatibility(const std::string& fileName) + bool CheckCompatibility(const std::string& fileName, bool isForAppend) { bool ok = false; // check that file is accessible if ( exists(fileName) ) { // check HDF5 && MED compatibility med_bool hdfok, medok; - MEDfileCompatibility(fileName.c_str(), &hdfok, &medok); - if ( hdfok && medok ) { + med_err r0 = MEDfileCompatibility(fileName.c_str(), &hdfok, &medok); + //MESSAGE(r0 << " " << hdfok << " " << medok); + if ( r0==0 && hdfok && medok ) { med_idt aFid = MEDfileOpen(fileName.c_str(), MED_ACC_RDONLY); if (aFid >= 0) { med_int major, minor, release; med_err ret = MEDfileNumVersionRd(aFid, &major, &minor, &release); + //MESSAGE(ret << " " << major << "." << minor << "." << release); if (ret >= 0) { - int version = 100*major + minor; - if (version >= 202) + bool isReadOnly = !isForAppend; + if ( isReadOnly || ((major == MED_MAJOR_NUM) && (minor == MED_MINOR_NUM))) ok = true; } } @@ -111,10 +114,10 @@ namespace MED return new MED::TWrapper(fileName); } - PWrapper CrWrapperW(const std::string& fileName) + PWrapper CrWrapperW(const std::string& fileName, int theMinor) { - if (!CheckCompatibility(fileName)) + if (!CheckCompatibility(fileName, true)) remove(fileName.c_str()); - return new MED::TWrapper(fileName); + return new MED::TWrapper(fileName, theMinor); } }