Changeset 2438 for XIOS3/trunk
- Timestamp:
- 12/07/22 13:07:07 (19 months ago)
- Location:
- XIOS3/trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS3/trunk/src/cxios.cpp
r2420 r2438 15 15 #include "servers_ressource.hpp" 16 16 #include "mem_checker.hpp" 17 #include <unistd.h> 17 18 18 19 namespace xios … … 71 72 { 72 73 set_new_handler(noMemory); 74 char startPath[256]; 75 getcwd(startPath, sizeof(startPath)); 76 if(const char* userPath = std::getenv("XIOS_IODEF_PATH")) 77 { 78 if ( chdir( userPath ) != 0) 79 { 80 ERROR("CXios::initialize()", << "XIOS_IODEF_PATH not defined correctly : " << userPath << endl ); 81 } 82 } 73 83 parseFile(rootFile); 74 84 parseXiosConfig(); 85 chdir( startPath ); 75 86 } 76 87 … … 199 210 std::set<StdString> parseList; 200 211 parseList.insert("xios"); 212 char startPath[256]; 213 getcwd(startPath, sizeof(startPath)); 214 if(const char* userPath = std::getenv("XIOS_IODEF_PATH")) 215 { 216 if ( chdir( userPath ) != 0) 217 { 218 ERROR("CXios::initialize()", << "XIOS_IODEF_PATH not defined correctly : " << userPath << endl ); 219 } 220 } 201 221 xml::CXMLParser::ParseFile(rootFile, parseList); 202 222 parseXiosConfig(); 223 chdir( startPath ); 203 224 } 204 225 -
XIOS3/trunk/src/node/context.cpp
r2426 r2438 35 35 #include <chrono> 36 36 #include <random> 37 #include <unistd.h> 37 38 38 39 namespace xios … … 162 163 if (attributes.end() != attributes.find("src")) 163 164 { 164 StdIFStream ifs ( attributes["src"].c_str() , StdIFStream::in ); 165 string srcString = attributes["src"].c_str(); 166 167 // check if environment variables 168 string srcKey; 169 if (srcString.find("${") == 0) // src start wit 170 { 171 size_t envVarStart = srcString.find("${")+2; // +2 for ${ 172 if (srcString.find("}") != std::string::npos) 173 { 174 size_t envVarEnd = srcString.find("}")-2; // -2 (start @ srcString begining, not after ${ 175 if(const char* var_path = std::getenv( srcString.substr( envVarStart, envVarEnd ).c_str() ) ) 176 { 177 srcKey=string(var_path)+"/"+srcString.substr( srcString.find("}")+1, srcString.size()-srcString.find("}") ); 178 } 179 else 180 { 181 ERROR("void CContext::parse(xml::CXMLNode & node)", 182 <<endl<< "The src key " << attributes["src"].c_str()<< " contains an undefined variable." ); 183 } 184 } 185 else 186 { 187 ERROR("void CContext::parse(xml::CXMLNode & node)", 188 <<endl<< "The src key " << attributes["src"].c_str()<< " not defined correctly." ); 189 } 190 } 191 else if (srcString.find("${") != 0) 192 { 193 ERROR("void CContext::parse(xml::CXMLNode & node)", 194 <<endl<< "The src key " << attributes["src"].c_str()<< " should start with $" ); 195 } 196 else if (srcString.find("$") != std::string::npos) 197 { 198 ERROR("void CContext::parse(xml::CXMLNode & node)", 199 <<endl<< "The src key " << attributes["src"].c_str()<< " need { and }." ); 200 } 201 else // standard behavor, without environment variable 202 { 203 srcKey = attributes["src"].c_str(); 204 } 205 206 StdIFStream ifs ( srcKey , StdIFStream::in ); 165 207 if ( (ifs.rdstate() & std::ifstream::failbit ) != 0 ) 208 { 209 char currentPath[256]; 210 getcwd(currentPath, sizeof(currentPath)); 166 211 ERROR("void CContext::parse(xml::CXMLNode & node)", 167 <<endl<< "Can not open <"<<attributes["src"].c_str()<<"> file" ); 212 <<endl<< "Can not open <"<<attributes["src"].c_str()<<"> file " 213 << "from iodef path : " << currentPath ); 214 } 168 215 if (!ifs.good()) 169 216 ERROR("CContext::parse(xml::CXMLNode & node)",
Note: See TracChangeset
for help on using the changeset viewer.