X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Ffs%2Funix%2Fdir.cpp;h=0dc950bf00da0b8ff82b5e26e25346be3170be41;hb=e2b5cb6cd61bf8c6f56f624cc835233df92288da;hp=69e926adf189e7087f3772b546248ad80079bd2a;hpb=cc7c798b275b8ea9992eb82d68177ecfd50e0974;p=libs%2Fcore.git diff --git a/source/fs/unix/dir.cpp b/source/fs/unix/dir.cpp index 69e926a..0dc950b 100644 --- a/source/fs/unix/dir.cpp +++ b/source/fs/unix/dir.cpp @@ -1,4 +1,3 @@ -#include #include #include #include @@ -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