]> git.tdb.fi Git - libs/core.git/blobdiff - source/fs/osx/dir_location.cpp
Add new exception classes for some common errors
[libs/core.git] / source / fs / osx / dir_location.cpp
index 7e9985b008228d25bce53ae5331839d4e933c428..13aa3d2d500fd167153f16b4811f575004e517af 100644 (file)
@@ -1,4 +1,6 @@
 #include <msp/core/application.h>
+#include <msp/core/environ.h>
+#include <msp/core/except.h>
 #include "dir.h"
 
 using namespace std;
@@ -16,23 +18,18 @@ Path get_home_dir()
        if(len)
                return string(buf, len);
 
-       const char *home = getenv("HOME");
-       if(home)
+       string home = getenv("HOME");
+       if(!home.empty())
                return home;
 
        return ".";
 }
 
-Path get_user_data_dir(const string &)
-{
-       return get_user_data_dir();
-}
-
 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");
 
        char buf[1024];
        unsigned len = get_application_support_dir(buf, sizeof(buf));