summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/filesystem/FileLocator.cpp67
1 files changed, 34 insertions, 33 deletions
diff --git a/src/plugins/filesystem/FileLocator.cpp b/src/plugins/filesystem/FileLocator.cpp
index 822c9fe..e11fd72 100644
--- a/src/plugins/filesystem/FileLocator.cpp
+++ b/src/plugins/filesystem/FileLocator.cpp
@@ -137,29 +137,9 @@ bool FileLocator::doLocate(Resource &resource, const std::string &path,
#ifdef FILELOCATOR_DEBUG_PRINT
std::cout << "FileLocator: Searching for \"" << path << "\"" << std::endl;
#endif
- if (!relativeTo.empty()) {
- fs::path base(relativeTo);
- if (fs::exists(base)) {
- // Look if 'relativeTo' is a directory already.
- if (!fs::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 (checkPath(resource, *this, base, type)) {
- return true;
- }
- }
- }
-
- // If the path starts with "./" or "../" only perform relative lookups!
- if (path.substr(0, 2) == "./" || path.substr(0, 3) == "../") {
- return false;
- }
+ // TODO: Check if with ./book.oxm relative paths are used and otherwise
+ // global search paths take precedence.
// If the path is an absolute path, look at this exact point.
{
@@ -172,23 +152,44 @@ bool FileLocator::doLocate(Resource &resource, const std::string &path,
}
}
}
-
- // Otherwise look in the search paths, search backwards, last defined search
- // paths have a higher precedence
- auto it = searchPaths.find(type);
- if (it != searchPaths.end()) {
- const auto &paths = it->second;
- for (auto it = paths.rbegin(); it != paths.rend(); it++) {
+ // If the path starts with "./" or "../" only perform relative lookups!
+ if (path.substr(0, 2) != "./" && path.substr(0, 3) != "../") {
+ // Look in the search paths, search backwards, last defined search
+ // paths have a higher precedence
+ auto it = searchPaths.find(type);
+ if (it != searchPaths.end()) {
+ const auto &paths = it->second;
+ for (auto it = paths.rbegin(); it != paths.rend(); it++) {
#ifdef FILELOCATOR_DEBUG_PRINT
- std::cout << "FileLocator: Entering " << *it << std::endl;
+ std::cout << "FileLocator: Entering " << *it << std::endl;
#endif
- fs::path p{*it};
- p /= path;
- if (checkPath(resource, *this, p, type)) {
+ fs::path p{*it};
+ p /= path;
+ if (checkPath(resource, *this, p, type)) {
+ return true;
+ }
+ }
+ }
+ }
+ if (!relativeTo.empty()) {
+ fs::path base(relativeTo);
+ if (fs::exists(base)) {
+ // Look if 'relativeTo' is a directory already.
+ if (!fs::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 (checkPath(resource, *this, base, type)) {
return true;
}
}
}
+
return false;
}