From 036694c0c851949b0a7ad65fb0ab16f7e3d3eda7 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 23 Sep 2009 20:11:54 +0000 Subject: [PATCH] Add get_sys_lib_dir function --- source/dir.cpp | 10 ++++++++++ source/dir.h | 3 +++ 2 files changed, 13 insertions(+) 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 &); -- 2.45.2