]> git.tdb.fi Git - libs/core.git/blobdiff - source/fs/unix/dir.cpp
Split getcwd and chdir to platform files
[libs/core.git] / source / fs / unix / dir.cpp
index 93aaeab5c73339e668af52e2f077e36839b98bbe..8169a63fffbe9809af24012ed4ae28101ac881e3 100644 (file)
@@ -21,6 +21,18 @@ void rmdir(const Path &path)
                throw system_error("rmdir");
 }
 
+Path getcwd()
+{
+       char buf[1024];
+       return ::getcwd(buf, sizeof(buf));
+}
+
+void chdir(const Path &path)
+{
+       if(::chdir(path.str().c_str())==-1)
+               throw system_error("chdir");
+}
+
 Path get_home_dir()
 {
        const char *home = getenv("HOME");
@@ -31,6 +43,8 @@ Path get_home_dir()
 
 Path get_user_data_dir(const string &appname)
 {
+       if(appname.empty())
+               throw invalid_argument("get_user_data_dir");
        return get_home_dir()/("."+appname);
 }