+/*
+This file is part of libmsppath
+Copyright © 2006 Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
#include <dirent.h>
#include <sys/stat.h>
#include <errno.h>
+#ifndef WIN32
#include <fnmatch.h>
+#endif
#include <msp/strutils.h>
#include "path.h"
#include "utils.h"
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