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