return access(path.str().c_str(), F_OK)==0;
}
+bool is_dir(const Path &path)
+{
+ struct stat st;
+ if(stat(path, st)==0)
+ return S_ISDIR(st.st_mode);
+ return false;
+}
+
Filename splitext(const string &fn)
{
Filename result;
return ::getcwd(buf, sizeof(buf));
}
+Path get_home_dir()
+{
+#ifndef WIN32
+ const char *home=getenv("HOME");
+ if(home)
+ return home;
+ return ".";
+#else
+ return ".";
+#endif
+}
+
} // namespace Msp
/// Tests for existence of a file
bool exists(const Path &path);
+/// Tests whether a path refers to an existing directory
+bool is_dir(const Path &paht);
+
/**
Gets information about a file. Returns 0 on success or -1 on error. This
version can be used to check for file existence and get information in one
Path getcwd();
+/// Returns the user's home directory
+Path get_home_dir();
+
inline bool is_windows_drive(const std::string &p)
{ return (p.size()==2 && ((p[0]>='A' && p[0]<='Z') || (p[0]>='a' && p[0]<='z')) && p[1]==':'); }