X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Ffs%2Fdir.cpp;h=00385e0d52d5602251719da1f3dc61859ccaecec;hp=ffe56708bffeb85552839e6867663470b9b0a418;hb=60260b5701bab73f8de093147de03947c7f264c8;hpb=ce0b610396aa8f760462fa4d7a6bb207a43994d2 diff --git a/source/fs/dir.cpp b/source/fs/dir.cpp index ffe5670..00385e0 100644 --- a/source/fs/dir.cpp +++ b/source/fs/dir.cpp @@ -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