From: rnv Date: Wed, 29 Jan 2020 17:11:07 +0000 (+0300) Subject: bos #17005 [CEA][Windows] cannot save study. X-Git-Tag: EMC2P_V_1_2_0~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c7ee135d7dff317410bc9639eaaca8d622ed8445;p=modules%2Fkernel.git bos #17005 [CEA][Windows] cannot save study. --- diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx index 579bf2348..05fa40fb4 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx @@ -801,13 +801,23 @@ bool SALOMEDSImpl_Study::Impl_SaveAs(const std::string& aStudyUrl, if ((fgets(buffer, 2046, fp)) == NULL) break; size_t aLen = strlen(buffer); if (buffer[aLen-1] == '\n') buffer[aLen-1] = char(0); -#ifdef WIN32 - aCmd = "move /Y \"" + aStudyTmpDir + std::string(buffer) + "\" \"" + SALOMEDSImpl_Tool::GetDirFromPath(aStudyUrl) +"\" 2>NUL"; + +#ifdef WIN32 + // Force removing readonly attribute from a file under Windows, because of a but in the HDF + std::string aReadOlnyRmCmd = "attrib -r \"" + aStudyTmpDir + std::string(buffer)+ "\" > nul 2>&1"; +#ifdef UNICODE + std::wstring awReadOlnyRmCmd = Kernel_Utils::utf8_decode_s(aReadOlnyRmCmd); + _wsystem(awReadOlnyRmCmd.c_str()); +#else + system(aReadOlnyRmCmd.c_str()); +#endif + + aCmd = "move /Y \"" + aStudyTmpDir + std::string(buffer) + "\" \"" + SALOMEDSImpl_Tool::GetDirFromPath(aStudyUrl) +"\" > nul 2>&1"; #else aCmd = "mv -f \"" + aStudyTmpDir + std::string(buffer) + "\" \"" + SALOMEDSImpl_Tool::GetDirFromPath(aStudyUrl)+"\""; #endif #if defined(WIN32) && defined(UNICODE) - std::wstring awCmd = Kernel_Utils::utf8_decode_s(aCmd); + std::wstring awCmd = Kernel_Utils::utf8_decode_s(aCmd); errors = _wsystem(awCmd.c_str()); #else errors = system(aCmd.c_str());