From 9568d4e48a6f3f56f0b49fab3b3b74cad2f86651 Mon Sep 17 00:00:00 2001 From: ilor <kailoran@gmail.com> Date: Thu, 5 May 2011 13:57:01 +0200 Subject: [PATCH] pathsearcher update: handle absolute (complete) paths, allow symlinks etc --- libpwrutils/pathsearch.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libpwrutils/pathsearch.cpp b/libpwrutils/pathsearch.cpp index c89b7a4..15f4e99 100644 --- a/libpwrutils/pathsearch.cpp +++ b/libpwrutils/pathsearch.cpp @@ -75,10 +75,21 @@ std::string PathSearcherBase::find_file(const std::string& filename, const std::string& info) { boost::filesystem::path i(filename); + if (i.is_complete()) { + if (boost::filesystem::exists(i) && + !boost::filesystem::is_directory(i)) { + if (verbose_loading_) { + std::cerr << "Found " << info << " file: " + << i.string() << "\n"; + } + return i.string(); + } + return ""; + } foreach (const std::string& s, paths_) { boost::filesystem::path pi = s / i; if (boost::filesystem::exists(pi) && - boost::filesystem::is_regular(pi)) { + !boost::filesystem::is_directory(pi)) { if (verbose_loading_) { std::cerr << "Found " << info << " file: " << pi.string() << "\n"; -- GitLab