namespace Msp {
namespace FS {
-/**
-Fixes the case of the given path to match files / directories on the
-filesystem. Intended to be used in programs that need to interact with
-emulated Windows programs.
-*/
+string basename(const Path &p)
+{
+ return p[-1];
+}
+
+Path dirname(const Path &p)
+{
+ return p.subpath(0, p.size()-1);
+}
+
+string basepart(const string &fn)
+{
+ unsigned dot=fn.rfind('.');
+ return fn.substr(0, dot);
+}
+
+string extpart(const string &fn)
+{
+ unsigned dot=fn.rfind('.');
+ if(dot==string::npos)
+ return string();
+ return fn.substr(dot);
+}
+
Path fix_case(const Path &path)
{
bool found=true;
throw SystemError("unlink failed", errno);
}
-Filename splitext(const string &fn)
-{
- Filename result;
- unsigned dot=fn.rfind('.');
- result.base=fn.substr(0, dot);
- if(dot!=string::npos)
- result.ext=fn.substr(dot);
- return result;
-}
-
-int fnmatch(const string &pat, const Path &fn)
-{
-#ifdef WIN32
- return globcasematch(pat, fn.str());
-#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();
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);
-}
-
} // namespace FS
} // namespace Msp