X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Futils.cpp;h=204f33bfdedcf841e6b4b4e0e090d9caa1824d67;hp=08ab9586a31700ed9a1399b35187caba5472f37c;hb=bfbb7edfb2ae76d23f26e0b22787617ff621747d;hpb=4cc2d6ced17e8cbe1ae3251069131d22a292b857 diff --git a/source/utils.cpp b/source/utils.cpp index 08ab958..204f33b 100644 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -158,5 +158,20 @@ int fnmatch(const string &pat, const Path &fn) #endif } +Path relative(const Path &path, const Path &base) +{ + Path::iterator i=path.begin(); + Path::iterator j=base.begin(); + for(; (i!=path.end() && j!=base.end() && *i==*j); ++i,++j); + + Path result; + for(; j!=base.end(); ++j) + result/=".."; + for(; i!=path.end(); ++i) + result/=*i; + + return result; +} + } // namespace Path } // namespace Msp