]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Unicode paths on Windows platform. rnv/unicode_paths
authorrnv <rnv@opencascade.com>
Tue, 30 May 2017 09:04:37 +0000 (12:04 +0300)
committerrnv <rnv@opencascade.com>
Tue, 30 May 2017 09:04:37 +0000 (12:04 +0300)
src/Basics/Basics_Utils.cxx
src/Basics/Basics_Utils.hxx
src/HDFPersist/CMakeLists.txt
src/HDFPersist/HDFascii.cc
src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx
src/SALOMEDSImpl/SALOMEDSImpl_Tool.cxx
src/SALOMEDSImpl/SALOMEDSImpl_Tool.hxx

index 73b4e800ee4bb566668877cfd708cee55bbd86ac..410a51f2e41b6775354f51219649738096ccbca5 100644 (file)
@@ -138,4 +138,23 @@ namespace Kernel_Utils
   #endif
 #endif
 
+#ifdef WIN32\r
+\r
+//Converts char* to windows wchar_t*\r
+wchar_t* ConvertToWideChar(const char* multibytearray) {\r
+               int wchars_num =  MultiByteToWideChar( CP_UTF8 , 0 , multibytearray , -1, NULL , 0 );\r
+               wchar_t* wstr = new wchar_t[wchars_num];\r
+               MultiByteToWideChar( CP_UTF8 , 0 , multibytearray , -1, wstr , wchars_num );\r
+               return wstr;\r
+}\r
+\r
+//Converts std::string to windows std::wstring\r
+std::wstring ConvertToWideString(std::string multibytearray) {\r
+       wchar_t* wstr = ConvertToWideChar(multibytearray.c_str());\r
+       std::wstring result(wstr);\r
+       delete[] wstr;\r
+       return result;\r
+}\r
+#endif\r
+
 }
index 5843afb7524c41a3232040f01c2e5edd05bb84ed..4ee692bb08dc256b7de7f22b049795e88f8aa15e 100644 (file)
@@ -65,6 +65,13 @@ namespace Kernel_Utils
   BASICS_EXPORT int setenv(const char*, const char*, int);
 #endif
 #endif
+
+#ifdef WIN32
+       //Converts char* to windows wchar_t*
+       BASICS_EXPORT wchar_t* ConvertToWideChar(const char* multibytearray);
+       //Converts std::string to windows std::wstring
+       BASICS_EXPORT std::wstring ConvertToWideString(std::string multibytearray);
+#endif
 }
 
 
index 58f9f92241dec82f95606ceaeee665e2cfd636a2..954cf664087e3d521d9bccd5662518a32a72b3e5 100755 (executable)
@@ -20,6 +20,7 @@
 INCLUDE_DIRECTORIES(
   ${HDF5_INCLUDE_DIRS}
   ${MPI_INCLUDE_DIRS}
+  ${CMAKE_CURRENT_SOURCE_DIR}/../Basics
 )
 
 FILE(GLOB SalomeHDFPersist_SOURCES_C "${CMAKE_CURRENT_SOURCE_DIR}/HDF*.c")
@@ -28,7 +29,12 @@ SET(SalomeHDFPersist_SOURCES ${SalomeHDFPersist_SOURCES_C} ${SalomeHDFPersist_SO
 ADD_DEFINITIONS(${HDF5_DEFINITIONS})
 
 ADD_LIBRARY(SalomeHDFPersist ${SalomeHDFPersist_SOURCES})
-TARGET_LINK_LIBRARIES(SalomeHDFPersist ${HDF5_LIBRARIES} ${MPI_LIBRARIES} ${PLATFORM_LIBS})
+SET(SalomeHDFPersist_libraries ${HDF5_LIBRARIES} ${MPI_LIBRARIES} ${PLATFORM_LIBS})
+IF(WIN32)
+  SET(SalomeHDFPersist_libraries ${SalomeHDFPersist_libraries} SALOMEBasics)
+ENDIF()
+TARGET_LINK_LIBRARIES(SalomeHDFPersist ${SalomeHDFPersist_libraries})
+
 INSTALL(TARGETS SalomeHDFPersist EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
 
 FILE(GLOB COMMON_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx")
index 3060d9a242c8133cc0851a09f7bac64597005bf7..1b7937313bc951f276dc8be45eaff0138f651cac 100644 (file)
@@ -35,6 +35,7 @@
 #include <string>
 
 #ifdef WIN32
+#include <Basics_Utils.hxx>
 #include <io.h>
 #include <time.h>
 #include <windows.h>
@@ -86,7 +87,16 @@ void WriteSimpleData( FILE* fp, HDFdataset *hdf_dataset, hdf_type type, long siz
 //============================================================================
 bool HDFascii::isASCII(const char* thePath) {
   int fd;
-  if(!(fd = open(thePath, O_RDONLY))) return false;
+#ifdef WIN32           
+               wchar_t* wstr = Kernel_Utils::ConvertToWideChar(thePath);
+               if(!(fd = _wopen(wstr, O_RDONLY))) {
+                       delete wstr;
+                       return false;
+               }
+               delete wstr;
+#else
+       if(!(fd = open(thePath, O_RDONLY))) return false;
+#endif  
   char* aBuffer = new char[9];
   aBuffer[8] = (char)0;
   read(fd, aBuffer, 8); 
index d05604ea5428be950e64cac484388d40874defd3..0c20166e85106c673dbfe894b74cb7b0b1bf7af5 100644 (file)
@@ -913,12 +913,13 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const std::string& aStudyUrl,
     if(buffer[aLen-1] == '\n') buffer[aLen-1] = char(0);
 #ifdef WIN32
     aCmd = "move /Y \"" + aStudyTmpDir + std::string(buffer) + "\" \"" + SALOMEDSImpl_Tool::GetDirFromPath(aStudyUrl) +"\"";
+               std::wstring wstr = Kernel_Utils::ConvertToWideString(aCmd);
+               errors = _wsystem(wstr.c_str());
 #else 
     aCmd = "mv -f \"" + aStudyTmpDir + std::string(buffer) + "\" \"" + SALOMEDSImpl_Tool::GetDirFromPath(aStudyUrl)+"\"";
+               errors = system(aCmd.c_str());
 #endif
-    errors = system(aCmd.c_str());
   }
-
   delete []buffer;
   fclose(fp);
 
index 61eed7dda67b89b22f75726defbf53df19fbbeef..270b57cf36718bc386c534ac747e0904792a6710 100644 (file)
@@ -382,4 +382,3 @@ std::string SALOMEDSImpl_Tool::GetUserName()
 
 
 
-
index 16cbbaf57f9c59bbc8fbcae478f9c9a7f3f1f296..12c92683d4ad21086a157e6a286ebf1696d0e2a6 100644 (file)
@@ -78,7 +78,6 @@ public:
 
   //Returns a name of the user
   static std::string GetUserName();
-
 };
 #endif