X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Futils.cpp;h=204f33bfdedcf841e6b4b4e0e090d9caa1824d67;hp=a7037ce33640a5d876c17ba16430443a484e884c;hb=bfbb7edfb2ae76d23f26e0b22787617ff621747d;hpb=9a8993b390544fb3e6b23ed562e2a2d4a62e4a7c diff --git a/source/utils.cpp b/source/utils.cpp index a7037ce..204f33b 100644 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -1,7 +1,14 @@ +/* +This file is part of libmsppath +Copyright © 2006 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ #include #include #include +#ifndef WIN32 #include +#endif #include #include "path.h" #include "utils.h" @@ -144,7 +151,26 @@ Filename splitext(const string &fn) int fnmatch(const string &pat, const Path &fn) { +#ifdef WIN32 + return -1; +#else return ::fnmatch(pat.c_str(), fn.str().c_str(), FNM_PATHNAME); +#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