X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FConfig%2FConfig_XMLReader.cpp;h=4cd1149f8db927c8669506b1507e5b22cebbcb33;hb=b5893b0a30fac08134c24de4565cb513a43affa6;hp=c08238a08de361d8ef55d9de14c91c5f64bb9df2;hpb=aace2d159972065be99071faeb0fdd9dd873131e;p=modules%2Fshaper.git diff --git a/src/Config/Config_XMLReader.cpp b/src/Config/Config_XMLReader.cpp index c08238a08..4cd1149f8 100644 --- a/src/Config/Config_XMLReader.cpp +++ b/src/Config/Config_XMLReader.cpp @@ -11,9 +11,10 @@ #include #include #include +#include #include -#include +#include #include #include @@ -27,10 +28,16 @@ #include #endif +#ifdef WIN32 + static const char FSEP = '\\'; +#else + static const char FSEP = '/'; +#endif + Config_XMLReader::Config_XMLReader(const std::string& theXmlFileName) : myXmlDoc(NULL) { - std::string prefix = ""; + std::string prefix = ""; Config_Prop* aProp = Config_PropManager::findProp("Plugins", "default_path"); if (aProp) prefix = aProp->value(); @@ -40,20 +47,13 @@ Config_XMLReader::Config_XMLReader(const std::string& theXmlFileName) * the problem: application may be launched using python executable, * to use environment variable (at least for the current moment) */ - if (prefix.empty()) { - char* anEnv = getenv("PLUGINS_CONFIG_FILE"); - if (anEnv) { - prefix = std::string(anEnv); - } - } -#ifdef WIN32 - prefix += "\\"; -#else - prefix += "/"; -#endif - myDocumentPath = prefix + theXmlFileName; + if (prefix.empty()) + prefix = pluginConfigFile(); + + myDocumentPath = prefix + FSEP + theXmlFileName; std::ifstream aTestFile(myDocumentPath); - if (!aTestFile) Events_Error::send("Unable to open " + myDocumentPath); + if (!aTestFile) + Events_InfoMessage("Config_XMLReader", "Unable to open %1").arg(myDocumentPath).send(); aTestFile.close(); } @@ -62,8 +62,27 @@ Config_XMLReader::~Config_XMLReader() xmlFreeDoc(myXmlDoc); } +std::string Config_XMLReader::pluginConfigFile() +{ + std::string aValue; + char* anEnv = getenv("SHAPER_ROOT_DIR"); + if (anEnv) { + aValue = std::string(anEnv) + + FSEP + "share" + FSEP + "salome" + FSEP + "resources" + FSEP + "shaper"; + } else { + anEnv = getenv("OPENPARTS_ROOT_DIR"); + if (anEnv) { + aValue = std::string(anEnv) + FSEP + "plugins"; + } + } + return aValue; +} + void Config_XMLReader::readAll() { + // to load external modules dependencies (like GEOm for Connector Feature + Config_ModuleReader::loadScript("salome.shaper.initConfig", false); + xmlNodePtr aRoot = findRoot(); readRecursively(aRoot); } @@ -184,3 +203,8 @@ bool Config_XMLReader::cleanupAttribute(const char* theNodeName, const char* the } return result; } + +const char* Config_XMLReader::encoding() const +{ + return (const char*) myXmlDoc->encoding; +} \ No newline at end of file