3 #include <boost/filesystem.hpp> 9 boost::filesystem::path
const& argv0,
10 std::function<
char const*(
char const*)> getenv,
11 char const* program_root_variable)
16 fs::path sysconf_leaf = sysconfdir.filename();
17 fs::path bin_leaf = bindir.filename();
20 if (program_root_variable !=
nullptr) {
21 char const* program_root = getenv(program_root_variable);
22 if (program_root !=
nullptr) {
23 fs::path dir = fs::path(program_root) / sysconf_leaf;
29 char const* system_root = getenv(
"JAYBEAMS_ROOT");
30 if (system_root !=
nullptr) {
31 fs::path dir = fs::path(system_root) / sysconf_leaf;
41 fs::path program(argv0);
42 if (program.parent_path().filename() == bin_leaf) {
43 fs::path dir = program.parent_path().parent_path() / sysconf_leaf;
45 }
else if (program.parent_path() !=
"") {
51 boost::filesystem::path
const& argv0,
52 std::function<
char const*(
char const*)> getenv)
57 return std::getenv(name);
61 return fs::exists(dir);
67 #ifndef JB_DEFAULT_SYSCONFDIR 68 #define JB_DEFAULT_SYSCONFDIR "/etc" 69 #endif // JB_DEFAULT_SYSCONFDIR 70 #ifndef JB_DEFAULT_BINDIR 71 #define JB_DEFAULT_BINDIR "/usr/bin" 72 #endif // JB_DEFAULT_BINDIR 75 #if defined(JB_SYSCONFDIR) 79 #endif // JB_SYSCONFDIR 83 #if defined(JB_BINDIR) std::vector< boost::filesystem::path > search_path_
#define JB_DEFAULT_BINDIR
char const * operator()(char const *name)
bool operator()(boost::filesystem::path const &path)
Define the configuration file search algorithm for JayBeams.
config_files_locations_base(boost::filesystem::path const &argv0, std::function< char const *(char const *)> getenv, char const *program_root_variable)
Constructor.
char const * bindir()
Return the binary installation directory directory.
#define JB_DEFAULT_SYSCONFDIR
char const * sysconfdir()
Return the system configuration directory.