+}
+
+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;
+}
+
+/**
+Extracts the basename from the given path. Same thing as Path::Path(p)[-1],
+but faster.
+*/
+string basename(const std::string &p);
+{
+ unsigned slash=p.rfind(DIRCHAR);
+ if(slash==string::npos)
+ return p;
+ else
+ return p.substr(slash+1);
+}