From 5fde58b21baa7d92194c7910a85ab542a61897a9 Mon Sep 17 00:00:00 2001 From: Benjamin Paassen Date: Fri, 12 Dec 2014 10:37:23 +0100 Subject: Made the relativeTo handling in FileLocator.cpp somewhat more sophisticated. --- src/plugins/boost/FileLocator.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/boost/FileLocator.cpp b/src/plugins/boost/FileLocator.cpp index ed9d0c9..3db214f 100644 --- a/src/plugins/boost/FileLocator.cpp +++ b/src/plugins/boost/FileLocator.cpp @@ -42,13 +42,20 @@ ResourceLocator::Location FileLocator::locate(const std::string &path, const Type type) const { boost::filesystem::path base(relativeTo); - // use the / operator to append the path. - base /= path; - // if we already found a fitting resource there, use that. if (boost::filesystem::exists(base)) { - std::string location = - boost::filesystem::canonical(base).generic_string(); - return ResourceLocator::Location(true, *this, type, location); + // look if 'relativeTo' is a directory already. + if (!boost::filesystem::is_directory(base)) { + // if not we use the parent directory. + base = base.parent_path(); + } + // use the / operator to append the path. + base /= path; + // if we already found a fitting resource there, use that. + if (boost::filesystem::exists(base)) { + std::string location = + boost::filesystem::canonical(base).generic_string(); + return ResourceLocator::Location(true, *this, type, location); + } } // otherwise look in the search paths. auto it = searchPaths.find(type); -- cgit v1.2.3