X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Futils.cpp;fp=source%2Futils.cpp;h=4036225a0f2af593584931d1205fe64aeab82199;hp=8f06757bda2227f69aa075acc045f1046dba1ce6;hb=0875a4cbef5e6d664488d8af2c37b3b252856750;hpb=aa31c2bbb399ded6493f7edc419b1a500ed25895 diff --git a/source/utils.cpp b/source/utils.cpp index 8f06757..4036225 100644 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -165,5 +165,21 @@ Path relative(const Path &path, const Path &base) return result; } +int descendant_depth(const Path &path, const Path &parent) +{ + Path::Iterator i=path.begin(); + Path::Iterator j=parent.begin(); + for(; (i!=path.end() && j!=parent.end() && *i==*j); ++i, ++j) ; + + if(j!=parent.end()) + return -1; + + int result = 0; + for(; i!=path.end(); ++i) + ++result; + + return result; +} + } // namespace FS } // namespace Msp