-#include <cstdlib>
+#include <msp/core/application.h>
+#include <msp/core/environ.h>
+#include <msp/core/except.h>
#include "dir.h"
using namespace std;
Path get_home_dir()
{
- const char *home = getenv("HOME");
- if(home)
+ string home = getenv("HOME");
+ if(!home.empty())
return home;
return ".";
}
-Path get_user_data_dir(const string &appname)
+Path get_user_data_dir()
{
+ const string &appname = Application::get_name();
if(appname.empty())
- throw invalid_argument("get_user_data_dir");
+ throw invalid_state("no application name");
+
return get_home_dir()/("."+appname);
}