X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDWrapper%2FMED_Wrapper.cxx;h=5b132c0518a0359f52c8aaf71336c51d440f655b;hb=6af512d41a2a0163584931724010aaa1ccf6aac8;hp=85a8d9f35d1214b01962c4f13f3c2735f404f654;hpb=e63b88c7f344d9a9a6b398b25305c8c610dfcdf0;p=modules%2Fsmesh.git diff --git a/src/MEDWrapper/MED_Wrapper.cxx b/src/MEDWrapper/MED_Wrapper.cxx index 85a8d9f35..5b132c051 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,14 +28,18 @@ #include #include +#ifdef WIN32 +#include +#endif + #include #ifdef _DEBUG_ static int MYDEBUG = 0; static int MYVALUEDEBUG = 0; #else -static int MYDEBUG = 0; -static int MYVALUEDEBUG = 0; +// static int MYDEBUG = 0; // unused in release mode +// static int MYVALUEDEBUG = 0; // unused in release mode #endif namespace MED @@ -78,13 +82,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,12 +104,29 @@ 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); +#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) *theErr = TErr(myFid); else if (myFid < 0) - EXCEPTION(std::runtime_error,"TFile - MEDfileVersionOpen('"<