From 62b0623bd7e56d6399dc32ddaeb1c63b8f6e4737 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 19 Feb 2011 04:59:55 +0000 Subject: Fix Path::relative_to_base. git-svn-id: http://svn.drobilla.net/lad/trunk/raul@2992 a436a847-0d15-0410-975c-d299462d15a1 --- raul/Path.hpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'raul/Path.hpp') diff --git a/raul/Path.hpp b/raul/Path.hpp index e59da60..c399767 100644 --- a/raul/Path.hpp +++ b/raul/Path.hpp @@ -113,7 +113,9 @@ public: static std::string pathify(const std::basic_string& str); static std::string nameify(const std::basic_string& str); - static void replace_invalid_chars(std::string& str, size_t start, bool replace_slash = false); + static void replace_invalid_chars(std::string& str, + size_t start, + bool replace_slash = false); bool is_root() const { return (*this) == root(); } @@ -164,26 +166,23 @@ public: } } - /** Return the path's child with the given name (symbol) */ inline Path child(const Raul::Symbol& symbol) const { return base() + symbol.c_str(); } - /** Return path relative to some base path (chop prefix) */ inline Path relative_to_base(const Path& base) const { if ((*this) == base) { return "/"; } else { - assert(length() > base.length()); - return substr(base.length() - 1); + assert(length() > base.base().length()); + return substr(base.base().length() - 1); } } - /** Return path with a trailing "/". * * Returned value is guaranteed to be a valid parent path, i.e. a valid @@ -206,7 +205,6 @@ public: return base().substr(find(":") + 1); } - /** Return true if \a child is equal to, or a descendant of \a parent */ static bool descendant_comparator(const Path& parent, const Path& child) { return ( child == parent || (child.length() > parent.length() && -- cgit v1.2.1