Allow defining monitordirs variable: subset/dir of topdirs which will get monitored for updates

This commit is contained in:
Jean-Francois Dockes
2018-04-11 17:45:06 +02:00
parent 68e6b9f8d0
commit 8559572c7e
6 changed files with 90 additions and 28 deletions
+23
View File
@@ -353,6 +353,29 @@ bool path_isroot(const string& path)
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)
{
if (!path.empty() && (path[0] == '/'
+4
View File
@@ -113,6 +113,10 @@ extern bool path_isabsolute(const std::string& s);
/// Test if path is root (x:/). root is defined by root/.. == root
extern bool path_isroot(const std::string& p);
/// Test if sub is a subdirectory of top. This is a textual test,
/// links not allowed
extern bool path_isdesc(const std::string& top, const std::string& sub);
/// Turn absolute path into file:// url
extern std::string path_pathtofileurl(const std::string& path);