XML_Node* Application::get_XML_File(const std::string& file, int debug) { std::unique_lock<std::mutex> xmlLock(xml_mutex); std::string path = ""; path = findInputFile(file); int mtime = get_modified_time(path); if (xmlfiles.find(path) != xmlfiles.end()) { // Already have a parsed XML tree for this file cached. Check the // last-modified time. std::pair<XML_Node*, int> cache = xmlfiles[path]; if (cache.second == mtime) { return cache.first; } } /* * Check whether or not the file is XML (based on the file extension). If * not, it will be first processed with the preprocessor. */ string::size_type idot = path.rfind('.'); string ext; if (idot != string::npos) { ext = path.substr(idot, path.size()); } else { ext = ""; } XML_Node* x = new XML_Node("doc"); if (ext != ".xml" && ext != ".ctml") { // Assume that we are trying to open a cti file. Do the conversion to XML. std::stringstream phase_xml(ct2ctml_string(path)); x->build(phase_xml); } else { std::ifstream s(path.c_str()); if (s) { x->build(s); } else { throw CanteraError("get_XML_File", "cannot open "+file+" for reading.\n" "Note, this error indicates a possible configuration problem."); } } x->lock(); xmlfiles[path] = {x, mtime}; return x; }