X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Ffs%2Fdir.cpp;h=df85e352ee78c05874b40ac6d406c421db816a04;hp=ffe56708bffeb85552839e6867663470b9b0a418;hb=9db96b7d13927640e03f760707b6f7aa044f1a13;hpb=cc7c798b275b8ea9992eb82d68177ecfd50e0974 diff --git a/source/fs/dir.cpp b/source/fs/dir.cpp index ffe5670..df85e35 100644 --- a/source/fs/dir.cpp +++ b/source/fs/dir.cpp @@ -141,7 +141,7 @@ Path get_user_data_dir() const string &name = Application::get_name(); if(name.empty()) throw logic_error("application name not known"); - return get_user_data_dir(); + return get_user_data_dir(name); } Path get_sys_conf_dir(const string &argv0) @@ -220,5 +220,24 @@ void chdir(const Path &path) throw system_error("chdir"); } +Path path_lookup(const string &name, const list &paths) +{ + for(list::const_iterator i=paths.begin(); i!=paths.end(); ++i) + { + Path full = *i/name; + if(exists(full)) + return realpath(full); + } + + return Path(); +} + +Path path_lookup(const string &name) +{ + const char *path = getenv("PATH"); + vector dirs = split(path, ITEMSEP); + return path_lookup(name, list(dirs.begin(), dirs.end())); +} + } // namespace FS } // namespace Msp