]> git.tdb.fi Git - libs/core.git/blobdiff - source/fs/unix/dir_location.cpp
Add wrappers for environment manipulation functions
[libs/core.git] / source / fs / unix / dir_location.cpp
index e81b8b97a55bba9b5fcc5e806018b494da84f3ac..73825875fd4df979ae1b7c5fff619af6982fb133 100644 (file)
@@ -1,4 +1,5 @@
-#include <cstdlib>
+#include <msp/core/application.h>
+#include <msp/core/environ.h>
 #include "dir.h"
 
 using namespace std;
@@ -8,16 +9,18 @@ namespace FS {
 
 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 logic_error("no application name");
+
        return get_home_dir()/("."+appname);
 }