From 36a8243f732e4439a77bfa6c811306c2e1967624 Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Sat, 27 Aug 2011 11:52:05 +0200 Subject: [PATCH] Support absolute paths for XML includes. Use standard path resolver when searching for includes. Includes like are now also supported - no need for . --- simgear/props/props_io.cxx | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/simgear/props/props_io.cxx b/simgear/props/props_io.cxx index 9fea4497..0877390e 100644 --- a/simgear/props/props_io.cxx +++ b/simgear/props/props_io.cxx @@ -21,6 +21,7 @@ #include #include #include +#include #include "props.hxx" #include "props_io.hxx" @@ -170,12 +171,15 @@ PropsVisitor::startElement (const char * name, const XMLAttributes &atts) // Check for an include. attval = atts.getValue("include"); if (attval != 0) { - SGPath path(SGPath(_base).dir()); - path.append(attval); try { - readProperties(path.str(), _root, 0, _extended); + SGPath path = simgear::ResourceManager::instance()->findPath(attval, SGPath(_base).dir()); + if (path.isNull()) + { + throw sg_io_exception("Cannot open file", sg_location(attval)); + } + readProperties(path.str(), _root, 0, _extended); } catch (sg_io_exception &e) { - setException(e); + setException(e); } } @@ -242,12 +246,15 @@ PropsVisitor::startElement (const char * name, const XMLAttributes &atts) bool omit = false; attval = atts.getValue("include"); if (attval != 0) { - SGPath path(SGPath(_base).dir()); - path.append(attval); try { - readProperties(path.str(), node, 0, _extended); + SGPath path = simgear::ResourceManager::instance()->findPath(attval, SGPath(_base).dir()); + if (path.isNull()) + { + throw sg_io_exception("Cannot open file", sg_location(attval)); + } + readProperties(path.str(), node, 0, _extended); } catch (sg_io_exception &e) { - setException(e); + setException(e); } attval = atts.getValue("omit-node"); -- 2.39.5