From: Scott Cantor Date: Sun, 20 May 2012 18:49:08 +0000 (+0000) Subject: Add path resolution and env expansion to catalog path. X-Git-Tag: 1.5.0~17 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fcpp-xmltooling.git;a=commitdiff_plain;h=24f6c0a5e8a13de058a15d1404fbbabb852db824 Add path resolution and env expansion to catalog path. --- diff --git a/xmltooling/util/ParserPool.cpp b/xmltooling/util/ParserPool.cpp index 712b121..3650297 100644 --- a/xmltooling/util/ParserPool.cpp +++ b/xmltooling/util/ParserPool.cpp @@ -29,6 +29,7 @@ #include "logging.h" #include "util/CurlURLInputStream.h" #include "util/NDC.h" +#include "util/PathResolver.h" #include "util/ParserPool.h" #include "util/Threads.h" #include "util/XMLHelper.h" @@ -39,7 +40,6 @@ #include #include #include -#include #include #include #include @@ -240,13 +240,13 @@ bool ParserPool::loadSchema(const XMLCh* nsURI, const XMLCh* pathname) bool ParserPool::loadCatalogs(const char* pathnames) { string temp(pathnames); - boost::tokenizer< char_separator > catpaths(temp, char_separator(PATH_SEPARATOR_STR)); - for_each( - catpaths.begin(), catpaths.end(), - // Call loadCatalog with an inner call to s->c_str() on each entry. - boost::bind(static_cast(&ParserPool::loadCatalog), this, boost::bind(&string::c_str, _1)) - ); - return catpaths.begin() != catpaths.end(); + vector catpaths; + split(catpaths, temp, is_any_of(PATH_SEPARATOR_STR), algorithm::token_compress_on); + for (vector::iterator i = catpaths.begin(); i != catpaths.end(); ++i) { + XMLToolingConfig::getConfig().getPathResolver()->resolve(*i, PathResolver::XMLTOOLING_XML_FILE); + loadCatalog(i->c_str()); + } + return !catpaths.empty(); } bool ParserPool::loadCatalog(const char* pathname) diff --git a/xmltooling/util/PathResolver.cpp b/xmltooling/util/PathResolver.cpp index 0277e0b..4ca48ec 100644 --- a/xmltooling/util/PathResolver.cpp +++ b/xmltooling/util/PathResolver.cpp @@ -101,6 +101,16 @@ bool PathResolver::isAbsolute(const char* s) const const string& PathResolver::resolve(string& s, file_type_t filetype, const char* pkgname, const char* prefix) const { +#ifdef WIN32 + // Check for possible environment variable(s). + if (s.find('%') != string::npos) { + char expbuf[MAX_PATH + 2]; + DWORD cnt = ExpandEnvironmentStrings(s.c_str(), expbuf, sizeof(expbuf)); + if (cnt != 0 && cnt <= sizeof(expbuf)) + s = expbuf; + } +#endif + if (!isAbsolute(s.c_str())) { switch (filetype) { case XMLTOOLING_LIB_FILE: