]> git.tdb.fi Git - libs/core.git/blobdiff - source/fs/unix/dir.cpp
Have get_user_data_dir return a proper location on Android
[libs/core.git] / source / fs / unix / dir.cpp
index 69e926adf189e7087f3772b546248ad80079bd2a..0dc950bf00da0b8ff82b5e26e25346be3170be41 100644 (file)
@@ -1,4 +1,3 @@
-#include <cstdlib>
 #include <unistd.h>
 #include <sys/stat.h>
 #include <msp/core/systemerror.h>
@@ -21,19 +20,16 @@ void rmdir(const Path &path)
                throw system_error("rmdir");
 }
 
-Path get_home_dir()
+Path getcwd()
 {
-       const char *home = getenv("HOME");
-       if(home)
-               return home;
-       return ".";
+       char buf[1024];
+       return ::getcwd(buf, sizeof(buf));
 }
 
-Path get_user_data_dir(const string &appname)
+void chdir(const Path &path)
 {
-       if(appname.empty())
-               throw invalid_argument("get_user_data_dir");
-       return get_home_dir()/("."+appname);
+       if(::chdir(path.str().c_str())==-1)
+               throw system_error("chdir");
 }
 
 } // namespace FS