From: Mikko Rasa Date: Wed, 23 Sep 2009 20:11:54 +0000 (+0000) Subject: Add get_sys_lib_dir function X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=036694c0c851949b0a7ad65fb0ab16f7e3d3eda7;p=libs%2Fcore.git Add get_sys_lib_dir function --- diff --git a/source/dir.cpp b/source/dir.cpp index 29c24c1..111378f 100644 --- a/source/dir.cpp +++ b/source/dir.cpp @@ -209,6 +209,16 @@ Path get_sys_data_dir(const string &argv0, const string &appname) return dir; } +Path get_sys_lib_dir(const string &argv0, const string &appname) +{ + Path dir=get_bin_dir(argv0); + + if(dir[-1]=="bin" || dir[-1]=="sbin") + return dir/".."/"lib"/appname; + else + return dir; +} + void chdir(const Path &path) { if(::chdir(path.str().c_str())==-1) diff --git a/source/dir.h b/source/dir.h index ebbe56c..53228cc 100644 --- a/source/dir.h +++ b/source/dir.h @@ -48,6 +48,9 @@ Path get_sys_conf_dir(const std::string &argv0); /// Returns a directory containing immutable system-wide data Path get_sys_data_dir(const std::string &argv0, const std::string &appname); +/// Returns a directory containing system-wide architecture-specific files +Path get_sys_lib_dir(const std::string &argv0, const std::string &appname); + /// Changes the current working directory void chdir(const Path &);