yoda is hosted by Hepforge, IPPP Durham
YODA - Yet more Objects for Data Analysis 2.0.0
Paths.cc
Go to the documentation of this file.
1// -*- C++ -*-
2//
3// This file is part of YODA -- Yet more Objects for Data Analysis
4// Copyright (C) 2008-2021 The YODA collaboration (see AUTHORS for details)
5//
6#include "YODA/Utils/Paths.h"
8#include "binreloc/binreloc.h"
9
10#include <cstring>
11
12using namespace std;
13
14namespace YODA {
15
16
17 string getLibPath() {
18 BrInitError error;
19 br_init_lib(&error);
20 char* temp = br_find_lib_dir(DEFAULTLIBDIR);
21 const string libdir(temp);
22 free(temp);
23 return libdir;
24 }
25
26 string getDataPath() {
27 BrInitError error;
28 br_init_lib(&error);
29 char* temp = br_find_data_dir(DEFAULTDATADIR);
30 const string sharedir(temp);
31 free(temp);
32 return sharedir + "/YODA";
33 }
34
35 vector<string> getYodaDataPath() {
36 vector<string> dirs;
37 // Use the YODA data path variable if set...
38 const char* env = getenv("YODA_DATA_PATH");
39 if (env) dirs = Utils::pathsplit(env);
40 // ... then, unless the path ends in :: ...
41 if (!env || strlen(env) < 2 || string(env).substr(strlen(env)-2) != "::") {
42 // ... fall back to the YODA data install path
43 dirs.push_back(getDataPath());
44 }
45 return dirs;
46 }
47
48
49}
#define br_find_data_dir
Definition binreloc.h:47
BrInitError
Definition binreloc.h:22
#define br_find_lib_dir
Definition binreloc.h:49
#define br_init_lib
Definition binreloc.h:41
Anonymous namespace to limit visibility.
std::vector< std::string > getYodaDataPath()
YODA data paths.
Definition Paths.cc:35
std::string getDataPath()
Get the path to the installed share/YODA/ data directory.
Definition Paths.cc:26
std::string getLibPath()
Get the path to the directory containing libYODA.
Definition Paths.cc:17