mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-12-25 17:00:35 +05:00
Run SALOME with UNICODE path on Windows platform.
This commit is contained in:
parent
cccc6496b1
commit
64c20fc0e7
@ -512,7 +512,13 @@ bool GEOM_Engine::Save(const char* theFileName)
|
|||||||
{
|
{
|
||||||
if(!_document) return false;
|
if(!_document) return false;
|
||||||
|
|
||||||
_OCAFApp->SaveAs(_document, theFileName);
|
#if defined(WIN32) && defined(UNICODE)
|
||||||
|
std::wstring aFileName = Kernel_Utils::utf8_decode_s(theFileName);
|
||||||
|
#else
|
||||||
|
std::string aFileName = theFileName;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
_OCAFApp->SaveAs( _document, aFileName.c_str() );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -524,8 +530,13 @@ bool GEOM_Engine::Save(const char* theFileName)
|
|||||||
//=============================================================================
|
//=============================================================================
|
||||||
bool GEOM_Engine::Load(const char* theFileName)
|
bool GEOM_Engine::Load(const char* theFileName)
|
||||||
{
|
{
|
||||||
|
#if defined(WIN32) && defined(UNICODE)
|
||||||
|
std::wstring aFileName = Kernel_Utils::utf8_decode_s(theFileName);
|
||||||
|
#else
|
||||||
|
std::string aFileName = theFileName;
|
||||||
|
#endif
|
||||||
Handle(TDocStd_Document) aDoc;
|
Handle(TDocStd_Document) aDoc;
|
||||||
if (_OCAFApp->Open(theFileName, aDoc) != PCDM_RS_OK) {
|
if (_OCAFApp->Open(aFileName.c_str(), aDoc) != PCDM_RS_OK) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,11 +258,11 @@ GEOMGUI* GeometryGUI::getLibrary( const QString& libraryName )
|
|||||||
if ( !myGUIMap.contains( libraryName ) ) {
|
if ( !myGUIMap.contains( libraryName ) ) {
|
||||||
// try to load library if it is not loaded yet
|
// try to load library if it is not loaded yet
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
QString dirs = getenv( "PATH" );
|
QString dirs = Qtx::getenv( "PATH" );
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
QString dirs = getenv( "DYLD_LIBRARY_PATH" );
|
QString dirs = Qtx::getenv( "DYLD_LIBRARY_PATH" );
|
||||||
#else
|
#else
|
||||||
QString dirs = getenv( "LD_LIBRARY_PATH" );
|
QString dirs = Qtx::getenv( "LD_LIBRARY_PATH" );
|
||||||
#endif
|
#endif
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
QString sep = ";";
|
QString sep = ";";
|
||||||
@ -309,11 +309,11 @@ GEOMPluginGUI* GeometryGUI::getPluginLibrary( const QString& libraryName )
|
|||||||
// try to load library if it is not loaded yet
|
// try to load library if it is not loaded yet
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
QString dirs = getenv( "PATH" );
|
QString dirs = Qtx::getenv( "PATH" );
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
QString dirs = getenv( "DYLD_LIBRARY_PATH" );
|
QString dirs = Qtx::getenv( "DYLD_LIBRARY_PATH" );
|
||||||
#else
|
#else
|
||||||
QString dirs = getenv( "LD_LIBRARY_PATH" );
|
QString dirs = Qtx::getenv( "LD_LIBRARY_PATH" );
|
||||||
#endif
|
#endif
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
QString sep = ";";
|
QString sep = ";";
|
||||||
|
@ -18,12 +18,14 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "GEOMUtils_XmlHandler.hxx"
|
#include "GEOMUtils_XmlHandler.hxx"
|
||||||
|
#include <Basics_Utils.hxx>
|
||||||
|
|
||||||
#include <libxml/parser.h>
|
#include <libxml/parser.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <algorithm>
|
||||||
#else
|
#else
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
@ -33,7 +35,7 @@
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
const char* env_var = "GEOM_PluginsList";
|
const char* env_var = "GEOM_PluginsList";
|
||||||
|
|
||||||
const xmlChar* root_tag = (xmlChar*)"geom-plugins";
|
const xmlChar* root_tag = (xmlChar*)"geom-plugins";
|
||||||
const xmlChar* plugin_tag = (xmlChar*)"geom-plugin";
|
const xmlChar* plugin_tag = (xmlChar*)"geom-plugin";
|
||||||
const xmlChar* name_tag = (xmlChar*)"name";
|
const xmlChar* name_tag = (xmlChar*)"name";
|
||||||
@ -75,91 +77,113 @@ namespace
|
|||||||
|
|
||||||
std::list<std::string> getPluginXMLFiles()
|
std::list<std::string> getPluginXMLFiles()
|
||||||
{
|
{
|
||||||
std::list<std::string> xmlPaths;
|
std::list<std::string> xmlPaths;
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
std::string sep = "\\";
|
#ifdef UNICODE
|
||||||
|
std::wstring sep = L"\\";
|
||||||
#else
|
#else
|
||||||
std::string sep = "/";
|
std::string sep = "\\";
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
std::string sep = "/";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( const char* var = getenv( env_var ) )
|
#if defined(WIN32) && defined(UNICODE)
|
||||||
{
|
std::wstring wenv_var = Kernel_Utils::utf8_decode_s(env_var);
|
||||||
std::string plugins = var;
|
if (const wchar_t* var = _wgetenv(wenv_var.c_str()))
|
||||||
|
{
|
||||||
|
std::wstring plugins = var;
|
||||||
|
#else
|
||||||
|
if (const char* var = getenv(env_var))
|
||||||
|
{
|
||||||
|
std::string plugins = var;
|
||||||
|
#endif
|
||||||
|
std::string::size_type from = 0, pos;
|
||||||
|
while (from < plugins.size())
|
||||||
|
{
|
||||||
|
#if defined(WIN32) && defined(UNICODE)
|
||||||
|
pos = plugins.find(L':', from);
|
||||||
|
std::wstring plugin;
|
||||||
|
#else
|
||||||
|
pos = plugins.find(':', from);
|
||||||
|
std::string plugin;
|
||||||
|
#endif
|
||||||
|
if (pos != std::string::npos)
|
||||||
|
plugin = plugins.substr(from, pos - from);
|
||||||
|
else
|
||||||
|
plugin = plugins.substr(from), pos = plugins.size();
|
||||||
|
from = pos + 1;
|
||||||
|
|
||||||
std::string::size_type from = 0, pos;
|
if (plugin.size() == 0) continue;
|
||||||
while ( from < plugins.size() )
|
#if defined(WIN32) && defined(UNICODE)
|
||||||
{
|
std::wstring pluginRoot = plugin + L"_ROOT_DIR";
|
||||||
pos = plugins.find( ':', from );
|
std::transform(pluginRoot.begin(), pluginRoot.end(), pluginRoot.begin(), ::toupper);
|
||||||
std::string plugin;
|
const wchar_t* rootDirGeom = _wgetenv(L"GEOM_ROOT_DIR");
|
||||||
if ( pos != std::string::npos )
|
const wchar_t* rootDirPlugin = _wgetenv(pluginRoot.c_str());
|
||||||
plugin = plugins.substr( from, pos-from );
|
#else
|
||||||
else
|
std::string pluginRoot = toUpper(plugin + "_ROOT_DIR");
|
||||||
plugin = plugins.substr( from ), pos = plugins.size();
|
|
||||||
from = pos + 1;
|
|
||||||
|
|
||||||
if ( plugin.size() == 0 ) continue;
|
|
||||||
|
|
||||||
std::string pluginRoot = toUpper( plugin+"_ROOT_DIR" );
|
|
||||||
|
|
||||||
const char* rootDirGeom = getenv( "GEOM_ROOT_DIR" );
|
const char* rootDirGeom = getenv("GEOM_ROOT_DIR");
|
||||||
const char* rootDirPlugin = getenv( pluginRoot.c_str() );
|
const char* rootDirPlugin = getenv(pluginRoot.c_str());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool fileOK = false;
|
||||||
|
if (rootDirGeom) {
|
||||||
|
|
||||||
|
#if defined(WIN32) && defined(UNICODE)
|
||||||
|
std::wstring xmlPath = rootDirGeom;
|
||||||
|
if (xmlPath[xmlPath.size() - 1] != sep[0])
|
||||||
|
xmlPath += sep;
|
||||||
|
xmlPath += L"share" + sep + L"salome" + sep + L"resources" + sep + L"geom" + sep + plugin + L".xml";
|
||||||
|
#else
|
||||||
|
std::string xmlPath = rootDirGeom;
|
||||||
|
if (xmlPath[xmlPath.size() - 1] != sep[0])
|
||||||
|
xmlPath += sep;
|
||||||
|
xmlPath += "share" + sep + "salome" + sep + "resources" + sep + "geom" + sep + plugin + ".xml";
|
||||||
|
#endif
|
||||||
|
|
||||||
bool fileOK = false;
|
|
||||||
if ( rootDirGeom ) {
|
|
||||||
std::string xmlPath = rootDirGeom;
|
|
||||||
if ( xmlPath[ xmlPath.size()-1 ] != sep[0] )
|
|
||||||
xmlPath += sep;
|
|
||||||
xmlPath += "share" + sep + "salome" + sep + "resources" + sep + "geom" + sep + plugin + ".xml";
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
fileOK = (GetFileAttributes(xmlPath.c_str()) != INVALID_FILE_ATTRIBUTES);
|
||||||
|
#else
|
||||||
|
fileOK = (access(xmlPath.c_str(), F_OK) == 0);
|
||||||
|
#endif
|
||||||
|
if (fileOK)
|
||||||
|
#if defined(WIN32) && defined(UNICODE)
|
||||||
|
xmlPaths.push_back(Kernel_Utils::utf8_encode_s(xmlPath));
|
||||||
|
#else
|
||||||
|
xmlPaths.push_back(xmlPath);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if (!fileOK && rootDirPlugin) {
|
||||||
|
#if defined(WIN32) && defined(UNICODE)
|
||||||
|
std::wstring xmlPath = rootDirPlugin;
|
||||||
|
if (xmlPath[xmlPath.size() - 1] != sep[0])
|
||||||
|
xmlPath += sep;
|
||||||
|
std::transform(plugin.begin(), plugin.end(), plugin.begin(), ::tolower);
|
||||||
|
xmlPath += L"share" + sep + L"salome" + sep + L"resources" + sep + plugin + sep + plugin + L".xml";
|
||||||
|
|
||||||
#ifdef UNICODE
|
|
||||||
//RNV: this is workaround for providing compilation,
|
|
||||||
// path should be processed as unicode string.
|
|
||||||
size_t length = strlen(xmlPath.c_str()) + sizeof(char);
|
|
||||||
wchar_t* aPath = new wchar_t[length + 1];
|
|
||||||
memset(aPath, '\0', length);
|
|
||||||
mbstowcs(aPath, xmlPath.c_str(), length);
|
|
||||||
#else
|
#else
|
||||||
const char* aPath = xmlPath.c_str();
|
std::string xmlPath = rootDirPlugin;
|
||||||
#endif
|
if (xmlPath[xmlPath.size() - 1] != sep[0])
|
||||||
fileOK = (GetFileAttributes(aPath) != INVALID_FILE_ATTRIBUTES);
|
xmlPath += sep;
|
||||||
#if UNICODE
|
xmlPath += "share" + sep + "salome" + sep + "resources" + sep + toLower(plugin) + sep + plugin + ".xml";
|
||||||
delete aPath;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
fileOK = (GetFileAttributes(xmlPath.c_str()) != INVALID_FILE_ATTRIBUTES);
|
||||||
#else
|
#else
|
||||||
fileOK = (access(xmlPath.c_str(), F_OK) == 0);
|
fileOK = (access(xmlPath.c_str(), F_OK) == 0);
|
||||||
#endif
|
#endif
|
||||||
if ( fileOK )
|
#if defined(WIN32) && defined(UNICODE)
|
||||||
xmlPaths.push_back( xmlPath );
|
xmlPaths.push_back(Kernel_Utils::utf8_encode_s(xmlPath));
|
||||||
}
|
|
||||||
if ( !fileOK && rootDirPlugin ) {
|
|
||||||
std::string xmlPath = rootDirPlugin;
|
|
||||||
if ( xmlPath[ xmlPath.size()-1 ] != sep[0] )
|
|
||||||
xmlPath += sep;
|
|
||||||
xmlPath += "share" + sep + "salome" + sep + "resources" + sep + toLower(plugin) + sep + plugin + ".xml";
|
|
||||||
#ifdef WIN32
|
|
||||||
#ifdef UNICODE
|
|
||||||
size_t length = strlen(xmlPath.c_str()) + sizeof(char);
|
|
||||||
wchar_t* aPath = new wchar_t[length+1];
|
|
||||||
memset(aPath, '\0', length);
|
|
||||||
mbstowcs(aPath, xmlPath.c_str(), length);
|
|
||||||
#else
|
#else
|
||||||
const char* aPath = xmlPath.c_str();
|
xmlPaths.push_back(xmlPath);
|
||||||
#endif
|
#endif
|
||||||
fileOK = (GetFileAttributes(aPath) != INVALID_FILE_ATTRIBUTES);
|
}
|
||||||
#if UNICODE
|
}
|
||||||
delete aPath;
|
return xmlPaths;
|
||||||
#endif
|
}
|
||||||
#else
|
|
||||||
fileOK = (access(xmlPath.c_str(), F_OK) == 0);
|
|
||||||
#endif
|
|
||||||
if ( fileOK )
|
|
||||||
xmlPaths.push_back( xmlPath );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return xmlPaths;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MYDEBUG
|
#ifdef MYDEBUG
|
||||||
@ -202,15 +226,15 @@ namespace GEOMUtils
|
|||||||
for ( fit = xmlPaths.begin(); fit != xmlPaths.end(); ++fit )
|
for ( fit = xmlPaths.begin(); fit != xmlPaths.end(); ++fit )
|
||||||
{
|
{
|
||||||
std::string fileName = *fit;
|
std::string fileName = *fit;
|
||||||
|
|
||||||
int options = XML_PARSE_HUGE | XML_PARSE_NOCDATA;
|
int options = XML_PARSE_HUGE | XML_PARSE_NOCDATA;
|
||||||
xmlDocPtr doc = xmlReadFile( fileName.c_str(), NULL, options );
|
xmlDocPtr doc = xmlReadFile( fileName.c_str(), NULL, options );
|
||||||
|
|
||||||
if ( doc )
|
if ( doc )
|
||||||
{
|
{
|
||||||
// get root node
|
// get root node
|
||||||
xmlNodePtr root = xmlDocGetRootElement(doc);
|
xmlNodePtr root = xmlDocGetRootElement(doc);
|
||||||
|
|
||||||
// check if it is plugins container node
|
// check if it is plugins container node
|
||||||
if (xmlStrcmp(root->name, root_tag) == 0)
|
if (xmlStrcmp(root->name, root_tag) == 0)
|
||||||
{
|
{
|
||||||
@ -249,13 +273,13 @@ namespace GEOMUtils
|
|||||||
} // end iteration through actions container node children
|
} // end iteration through actions container node children
|
||||||
} // end actions container node
|
} // end actions container node
|
||||||
} // end iterations through plugin node children
|
} // end iterations through plugin node children
|
||||||
|
|
||||||
if (data.name != "")
|
if (data.name != "")
|
||||||
info.push_back(data);
|
info.push_back(data);
|
||||||
} // end plugin node
|
} // end plugin node
|
||||||
} // end iterations through plugins container node children
|
} // end iterations through plugins container node children
|
||||||
} // end root node
|
} // end root node
|
||||||
|
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
//xmlCleanupParser();//vsr: xmlCleanupParser should not be called from the application
|
//xmlCleanupParser();//vsr: xmlCleanupParser should not be called from the application
|
||||||
} // end xml doc
|
} // end xml doc
|
||||||
|
@ -2532,21 +2532,14 @@ void GEOM_Gen_i::LoadPlugin(const std::string& theLibName)
|
|||||||
// check, if corresponding operations are already created
|
// check, if corresponding operations are already created
|
||||||
if (myOpCreatorMap.find(theLibName) == myOpCreatorMap.end()) {
|
if (myOpCreatorMap.find(theLibName) == myOpCreatorMap.end()) {
|
||||||
#if WIN32
|
#if WIN32
|
||||||
#if UNICODE
|
#if UNICODE
|
||||||
//RNV: this is workaround for providing compilation,
|
std::wstring strL = Kernel_Utils::utf8_decode_s(aPlatformLibName);
|
||||||
// path should be processed as unicode string.
|
const wchar_t* aPath = strL.c_str();
|
||||||
size_t length = strlen(aPlatformLibName.c_str()) + sizeof(char);
|
|
||||||
wchar_t* aPath = new wchar_t[length + 1];
|
|
||||||
memset(aPath, '\0', length);
|
|
||||||
mbstowcs(aPath, aPlatformLibName.c_str(), length);
|
|
||||||
#else
|
#else
|
||||||
const char* aPath = aPlatformLibName.c_str();
|
const char* aPath = aPlatformLibName.c_str();
|
||||||
#endif
|
#endif
|
||||||
// load plugin library
|
// load plugin library
|
||||||
LibHandle libHandle = LoadLib(aPath);
|
LibHandle libHandle = LoadLib(aPath);
|
||||||
#if UNICODE
|
|
||||||
delete aPath;
|
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
LibHandle libHandle = LoadLib(aPlatformLibName.c_str());
|
LibHandle libHandle = LoadLib(aPlatformLibName.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user