From 9b6be3949a33b8590d96c9204dcedcb7a8b2e94f Mon Sep 17 00:00:00 2001 From: rnv Date: Wed, 19 Jun 2019 15:27:06 +0300 Subject: [PATCH] Compilation on Windows. --- src/Container/SALOME_ContainerManager.cxx | 4 ++++ .../SALOME_ExternalServerLauncher.cxx | 21 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index 608fda19d..7e2f7c6c9 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -1404,7 +1404,11 @@ long SALOME_ContainerManager::SystemWithPIDThreadSafe(const std::vector +#else +#include +#include +#endif #include #include #include #include +#include constexpr char NAME_IN_NS[]="/ExternalServers"; @@ -55,8 +61,23 @@ SALOME_ExternalServerLauncher::~SALOME_ExternalServerLauncher() class ChdirRAII { public: +#ifndef WIN32 ChdirRAII(const std::string& wd):_wd(wd) { if(_wd.empty()) return ; char *pwd(get_current_dir_name()); _od = pwd; free(pwd); chdir(_wd.c_str()); } ~ChdirRAII() { if(_od.empty()) return ; chdir(_od.c_str()); } +#else + ChdirRAII(const std::string& wd) : _wd(wd) { + if (_wd.empty()) + return; + TCHAR pwd[MAX_PATH]; + GetCurrentDirectory(sizeof(pwd), pwd); + _od = Kernel_Utils::utf8_encode_s(pwd); + SetCurrentDirectory(Kernel_Utils::utf8_decode_s(_wd).c_str()); + } + ~ChdirRAII() { + if (_od.empty()) return; + SetCurrentDirectory(Kernel_Utils::utf8_decode_s(_od).c_str()); + } +#endif private: std::string _wd; std::string _od; -- 2.39.2