From 5505b791b76d9dd307582003ef4d8227e8fea74a Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Thu, 28 Aug 2014 16:54:08 +0000 Subject: [PATCH] Make get_XML_Node search for both XML and CTI input file formats This makes it possible to use species and reactions from external CTI files, rather than only external XML files, since the datasrc extension assumed in the cti->xml conversion is .xml. --- src/base/global.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/base/global.cpp b/src/base/global.cpp index 60fbd8b21..8a69568cc 100644 --- a/src/base/global.cpp +++ b/src/base/global.cpp @@ -231,6 +231,22 @@ XML_Node* get_XML_Node(const std::string& file_ID, XML_Node* root) "no file name given. file_ID = "+file_ID); db = root->findID(idstr, 3); } else { + try { + findInputFile(fname); + } catch (CanteraError& err) { + // See if the input file can be found with a different format + if (fname.rfind(".xml") == fname.size() - 4) { + fname.replace(fname.size() - 3, 3, "cti"); + } else if (fname.rfind(".cti") == fname.size() - 4) { + fname.replace(fname.size() - 3, 3, "xml"); + } + try { + findInputFile(fname); + } catch (CanteraError& err2) { + // rethrow the original error, which indicates the given file name + throw err; + } + } doc = get_XML_File(fname); if (!doc) throw CanteraError("get_XML_Node", "get_XML_File failed trying to open "+fname);