]> git.tdb.fi Git - libs/core.git/blobdiff - source/fs/unix/dir_location.cpp
Add new exception classes for some common errors
[libs/core.git] / source / fs / unix / dir_location.cpp
index c980bb27a08bf5f5357299a0072f815b16ddf523..68d82a27f968c37d14c1e2c42aafe1814e679570 100644 (file)
@@ -1,5 +1,6 @@
-#include <cstdlib>
 #include <msp/core/application.h>
+#include <msp/core/environ.h>
+#include <msp/core/except.h>
 #include "dir.h"
 
 using namespace std;
@@ -9,8 +10,8 @@ namespace FS {
 
 Path get_home_dir()
 {
-       const char *home = getenv("HOME");
-       if(home)
+       string home = getenv("HOME");
+       if(!home.empty())
                return home;
        return ".";
 }
@@ -19,7 +20,7 @@ Path get_user_data_dir()
 {
        const string &appname = Application::get_name();
        if(appname.empty())
-               throw logic_error("no application name");
+               throw invalid_state("no application name");
 
        return get_home_dir()/("."+appname);
 }