-#include <cstdlib>
#include <unistd.h>
#include <sys/stat.h>
#include <msp/core/systemerror.h>
throw system_error("rmdir");
}
-Path get_home_dir()
+Path getcwd()
{
- const char *home = getenv("HOME");
- if(home)
- return home;
- return ".";
+ char buf[1024];
+ return ::getcwd(buf, sizeof(buf));
}
-Path get_user_data_dir(const string &appname)
+void chdir(const Path &path)
{
- if(appname.empty())
- throw invalid_argument("get_user_data_dir");
- return get_home_dir()/("."+appname);
+ if(::chdir(path.str().c_str())==-1)
+ throw system_error("chdir");
}
} // namespace FS