X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Futils.cpp;h=18784b3a423bb8b5d165c79ef95d72db0d594877;hp=721fc69249a98f8d7a85a471eb39b6db167bf9a8;hb=3004842aa3281f26137c7332089068da7edb34af;hpb=9dc69f850aab362348787353a55a900a5d72c5dc diff --git a/source/utils.cpp b/source/utils.cpp index 721fc69..18784b3 100644 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -158,6 +158,14 @@ bool exists(const Path &path) return access(path.str().c_str(), F_OK)==0; } +bool is_dir(const Path &path) +{ + struct stat st; + if(stat(path, st)==0) + return S_ISDIR(st.st_mode); + return false; +} + Filename splitext(const string &fn) { Filename result; @@ -224,4 +232,16 @@ Path getcwd() return ::getcwd(buf, sizeof(buf)); } +Path get_home_dir() +{ +#ifndef WIN32 + const char *home=getenv("HOME"); + if(home) + return home; + return "."; +#else + return "."; +#endif +} + } // namespace Msp