-/**
-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);
-}
-
-int stat(const Path &fn, struct stat &st)
-{
- return ::stat(fn.str().c_str(), &st);
-}
-
-struct stat stat(const Path &fn)
-{
- struct stat st;
- if(stat(fn, st)==-1)
- throw SystemError("stat failed", errno);
- return st;
-}
-
-Path getcwd()
-{
- char buf[1024];
- return ::getcwd(buf, sizeof(buf));
-}
-
-Path get_home_dir()
-{
-#ifndef WIN32
- const char *home=getenv("HOME");
- if(home)
- return home;
- return ".";
-#else
- return ".";
-#endif
-}
-