X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ffs%2Funix%2Fdir.cpp;fp=source%2Ffs%2Funix%2Fdir.cpp;h=93aaeab5c73339e668af52e2f077e36839b98bbe;hb=609c9a508cfdc7b42c46c4f21d17639204165a00;hp=0000000000000000000000000000000000000000;hpb=b4806214e905752617691f851717033fd3f266c2;p=libs%2Fcore.git diff --git a/source/fs/unix/dir.cpp b/source/fs/unix/dir.cpp new file mode 100644 index 0000000..93aaeab --- /dev/null +++ b/source/fs/unix/dir.cpp @@ -0,0 +1,38 @@ +#include +#include +#include +#include +#include "dir.h" + +using namespace std; + +namespace Msp { +namespace FS { + +void mkdir(const Path &path, int mode) +{ + if(::mkdir(path.str().c_str(), mode)==-1) + throw system_error("mkdir"); +} + +void rmdir(const Path &path) +{ + if(::rmdir(path.str().c_str())==-1) + throw system_error("rmdir"); +} + +Path get_home_dir() +{ + const char *home = getenv("HOME"); + if(home) + return home; + return "."; +} + +Path get_user_data_dir(const string &appname) +{ + return get_home_dir()/("."+appname); +} + +} // namespace FS +} // namespace Msp