X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Ffs%2Fosx%2Fdir_location.cpp;fp=source%2Ffs%2Fosx%2Fdir_location.cpp;h=7ce89f7a33de31bdf83e76d31c3da513811ca437;hp=0000000000000000000000000000000000000000;hb=8e613903920ee006c2c84e1af5620d92fbfb8957;hpb=55a73ee19194aec4179955aed78798c120fb99af diff --git a/source/fs/osx/dir_location.cpp b/source/fs/osx/dir_location.cpp new file mode 100644 index 0000000..7ce89f7 --- /dev/null +++ b/source/fs/osx/dir_location.cpp @@ -0,0 +1,35 @@ +#include "dir.h" + +using namespace std; + +extern "C" unsigned get_home_dir(char *, unsigned); +extern "C" unsigned get_application_support_dir(char *, unsigned); + +namespace Msp { +namespace FS { + +Path get_home_dir() +{ + char buf[1024]; + unsigned len = ::get_home_dir(buf, sizeof(buf)); + if(len) + return string(buf, len); + + const char *home = getenv("HOME"); + if(home) + return home; + + return "."; +} + +Path get_user_data_dir(const string &appname) +{ + char buf[1024]; + unsigned len = get_application_support_dir(buf, sizeof(buf)); + if(len) + return Path(string(buf, len))/appname; + return get_home_dir()/"Library"/"Application Support"/appname; +} + +} // namespace FS +} // namespace Msp