--- a/src/utils/pathut.cpp
+++ b/src/utils/pathut.cpp
@@ -351,6 +351,29 @@
}
#endif
return false;
+}
+
+bool path_isdesc(const string& _top, const string& _sub)
+{
+ string top = path_canon(_top);
+ string sub = path_canon(_sub);
+ path_catslash(top);
+ path_catslash(sub);
+ for (;;) {
+ if (sub == top) {
+ return true;
+ }
+ string::size_type l = sub.size();
+ sub = path_getfather(sub);
+ if (sub.size() == l || sub.size() < top.size()) {
+ // At root or sub shorter than top: done
+ if (sub == top) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ }
}
bool path_isabsolute(const string& path)