X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FMEDWrapper%2FMED_Wrapper.cxx;h=79dc1996b22bc375040d5f9fa6756a1a7efa4f63;hp=dc1e3f53fb6915ac0188a0fcd9c216324180d150;hb=0a37d49f45028285190bc58d74921ecc0f2a1ad0;hpb=29fa6f3696b1a72716948c6e97a260cda288f6d0 diff --git a/src/MEDWrapper/MED_Wrapper.cxx b/src/MEDWrapper/MED_Wrapper.cxx index dc1e3f53f..79dc1996b 100644 --- a/src/MEDWrapper/MED_Wrapper.cxx +++ b/src/MEDWrapper/MED_Wrapper.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -28,6 +28,10 @@ #include #include +#ifdef WIN32 +#include +#endif + #include #ifdef _DEBUG_ @@ -100,6 +104,23 @@ namespace MED { if (myCount++ == 0) { const char* aFileName = myFileName.c_str(); +#ifdef WIN32 + if (med_access_mode(theMode) == MED_ACC_RDWR) { + // Force removing readonly attribute from a file under Windows, because of a bug in the HDF5 + std::string aReadOlnyRmCmd = "attrib -r \"" + myFileName + "\"> nul 2>&1"; +#ifdef UNICODE + const char* to_decode = aReadOlnyRmCmd.c_str(); + int size_needed = MultiByteToWideChar(CP_UTF8, 0, to_decode, strlen(to_decode), NULL, 0); + wchar_t* awReadOlnyRmCmd = new wchar_t[size_needed + 1]; + MultiByteToWideChar(CP_UTF8, 0, to_decode, strlen(to_decode), awReadOlnyRmCmd, size_needed); + awReadOlnyRmCmd[size_needed] = '\0'; + _wsystem(awReadOlnyRmCmd); + delete[] awReadOlnyRmCmd; +#else + system(aReadOlnyRmCmd.c_str()); +#endif + } +#endif myFid = MEDfileVersionOpen(aFileName,med_access_mode(theMode), myMajor, myMinor, MED_RELEASE_NUM); } if (theErr) @@ -2443,7 +2464,7 @@ namespace MED // write node ids SetCellInfo(theInfo, theMode, theErr); - if (theErr && theErr < 0) + if (theErr && *theErr < 0) return; // write diameter