+// LCOV_EXCL_START
+std::string Config_XMLReader::resourcesConfigFile()
+{
+ 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 + "resources";
+ }
+ }
+ return aValue;
+}
+
+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;
+}
+// LCOV_EXCL_STOP
+
+std::string Config_XMLReader::findConfigFile(const std::string theFileName, const int theFindIndex)
+{
+ int aResultIndex = 0;
+ for(int aSolution = 0; aSolution < 12; aSolution++) {
+ std::string aFileName;
+ if (aSolution == 0) {
+ Config_Prop* aProp = Config_PropManager::findProp("Plugins", "default_path");
+ if (!aProp)
+ continue;
+ aFileName = aProp->value();
+ } else {
+ std::ostringstream anEnvName;
+ if (aSolution == 1)
+ anEnvName<<"SHAPER_ROOT_DIR";
+ else if (aSolution == 2)
+ anEnvName<<"OPENPARTS_ROOT_DIR";
+ else
+ anEnvName<<"OPENPARTS_PLUGINS_DIR";
+
+ char* anEnv = getenv(anEnvName.str().c_str());
+ if (!anEnv)
+ continue;
+ if (aSolution > 2) { // there may be several paths separated by ";" symbol
+// LCOV_EXCL_START
+ std::string anEnvPart = anEnv;
+ size_t aPosStart = 0, aPosEnd;
+ for(int aSubNum = 0; aSubNum < aSolution - 3; aSubNum++) {
+ aPosStart++;
+ aPosStart = anEnvPart.find(';', aPosStart);
+ if (aPosStart == std::string::npos)
+ break;
+ }
+ if (aPosStart == std::string::npos)
+ break;
+ if (aPosStart != 0)
+ aPosStart++;
+ aPosEnd = anEnvPart.find(';', aPosStart);
+ aFileName = anEnvPart.substr(aPosStart,
+ aPosEnd == std::string::npos ? aPosEnd : aPosEnd - aPosStart) + FSEP;
+// LCOV_EXCL_STOP
+ } else {
+ aFileName = std::string(anEnv) + FSEP;
+ }
+ if (aSolution == 1)
+ aFileName += std::string("share") + FSEP + "salome" + FSEP + "resources" + FSEP + "shaper";
+ else if (aSolution == 2)
+ aFileName += "plugins";
+ }
+
+ aFileName += FSEP + theFileName;
+ std::ifstream aTestFile(aFileName);
+ if (aTestFile) {
+ if (aResultIndex == theFindIndex)
+ return aFileName;
+ aResultIndex++;
+ if (aSolution == 1) // don't allow SHAPER and OpenParts paths treated simultaneously
+ aSolution++;
+ }
+ }
+ return ""; // no files found
+}
+