diff options
author | Benjamin Paassen <bpaassen@techfak.uni-bielefeld.de> | 2014-12-12 10:37:23 +0100 |
---|---|---|
committer | Benjamin Paassen <bpaassen@techfak.uni-bielefeld.de> | 2014-12-12 10:37:23 +0100 |
commit | 5fde58b21baa7d92194c7910a85ab542a61897a9 (patch) | |
tree | 2903e9b0a5bbbbd6b1130e17f6d7813af3ed60f3 /src | |
parent | f4c635eb43575c68a77d21ba6de2a8bd1d5a49c5 (diff) |
Made the relativeTo handling in FileLocator.cpp somewhat more sophisticated.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/ResourceLocator.hpp | 2 | ||||
-rw-r--r-- | src/plugins/boost/FileLocator.cpp | 19 |
2 files changed, 15 insertions, 6 deletions
diff --git a/src/core/ResourceLocator.hpp b/src/core/ResourceLocator.hpp index 926b312..39c7b30 100644 --- a/src/core/ResourceLocator.hpp +++ b/src/core/ResourceLocator.hpp @@ -44,6 +44,8 @@ public: SCRIPT, // A Type System TYPESYS, + DOCUMENT, + ATTRIBUTES, // TODO: Aren't documents and attribute descriptors missing? // TODO: What is the purpose of these two? GENERIC_MODULE, 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); |