]> git.tdb.fi Git - libs/core.git/blob - source/fs/unix/dir_location.cpp
c980bb27a08bf5f5357299a0072f815b16ddf523
[libs/core.git] / source / fs / unix / dir_location.cpp
1 #include <cstdlib>
2 #include <msp/core/application.h>
3 #include "dir.h"
4
5 using namespace std;
6
7 namespace Msp {
8 namespace FS {
9
10 Path get_home_dir()
11 {
12         const char *home = getenv("HOME");
13         if(home)
14                 return home;
15         return ".";
16 }
17
18 Path get_user_data_dir()
19 {
20         const string &appname = Application::get_name();
21         if(appname.empty())
22                 throw logic_error("no application name");
23
24         return get_home_dir()/("."+appname);
25 }
26
27 } // namespace FS
28 } // namespace Msp