]> git.tdb.fi Git - libs/core.git/blobdiff - source/fs/unix/dir_location.cpp
Have get_user_data_dir return a proper location on Android
[libs/core.git] / source / fs / unix / dir_location.cpp
diff --git a/source/fs/unix/dir_location.cpp b/source/fs/unix/dir_location.cpp
new file mode 100644 (file)
index 0000000..e81b8b9
--- /dev/null
@@ -0,0 +1,25 @@
+#include <cstdlib>
+#include "dir.h"
+
+using namespace std;
+
+namespace Msp {
+namespace FS {
+
+Path get_home_dir()
+{
+       const char *home = getenv("HOME");
+       if(home)
+               return home;
+       return ".";
+}
+
+Path get_user_data_dir(const string &appname)
+{
+       if(appname.empty())
+               throw invalid_argument("get_user_data_dir");
+       return get_home_dir()/("."+appname);
+}
+
+} // namespace FS
+} // namespace Msp