21#include <RConfigure.h>
37#include <sys/syslimits.h>
42#include <libprocstat.h>
46namespace FoundationUtils {
49 char fixedLength[1024];
50 char *currWorkDir = fixedLength;
52 char *
result = currWorkDir;
57 if (fixedLength != currWorkDir) {
60 currWorkDir =
new char[
len];
67 }
while (!
result && errno == ERANGE);
69 std::string
output = currWorkDir;
76 if (fixedLength != currWorkDir) {
82std::string
MakePathRelative(
const std::string &path,
const std::string &base,
bool isBuildingROOT )
86 const char *currWorkDir = base.c_str();
87 size_t lenCurrWorkDir = strlen(currWorkDir);
88 if (
result.substr(0, lenCurrWorkDir) == currWorkDir) {
92 result.erase(0, lenCurrWorkDir);
98 int posInc =
result.find(
"/inc/");
108 std::replace(Path.begin(), Path.end(),
'\\',
'/');
112 static std::string fallback;
113 if (!fallback.empty())
116#if defined(WIN32) || defined(__FreeBSD__)
117 auto parent_path = [](std::string path) {
118 return path.substr(0, path.find_last_of(
"/\\"));
123 static char lpFilename[_MAX_PATH];
124 if (::GetModuleFileNameA(
127 sizeof(lpFilename))) {
128 fallback = parent_path(parent_path(lpFilename));
130#elif defined __FreeBSD__
131 procstat* ps = procstat_open_sysctl();
132 kinfo_proc* kp = kinfo_getproc(getpid());
134 char lpFilename[PATH_MAX] =
"";
136 procstat_getpathname(ps, kp, lpFilename,
sizeof(lpFilename));
137 fallback = parent_path(parent_path({lpFilename}));
146 fallback =
"/usr/local/root";
152static bool IgnorePrefix() {
153 static bool ignorePrefix = ::getenv(
"ROOTIGNOREPREFIX");
160 if (!IgnorePrefix()) {
161 const static std::string rootsys = ROOTPREFIX;
165 static std::string rootsys;
166 if (rootsys.empty()) {
167 if (
const char* envValue = ::getenv(
"ROOTSYS")) {
182 if (!IgnorePrefix()) {
183 const static std::string rootincdir = ROOTINCDIR;
187 static std::string rootincdir;
188 if (rootincdir.empty()) {
190 rootincdir =
GetRootSys() + sep +
"include" + sep;
197 if (!IgnorePrefix()) {
198 const static std::string rootetcdir = ROOTETCDIR;
203 const static std::string rootetcdir =
209 std::transform(s.begin(), s.end(), s.begin(),
210 [](
unsigned char c){ return std::tolower(c); });
The file contains utilities which are foundational and could be used across the core component of ROO...
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
static int lowercase(const char *s)
const std::string & GetPathSeparator()
const std::string & GetIncludeDir()
\ returns the include directory in the installation.
std::string GetCurrentDir()
static std::string str_tolower(std::string s)
void ConvertToUnixPath(std::string &Path)
Transforms a file path by replacing its backslashes with slashes.
bool CanConvertEnvValueToBool(const std::string &value)
const std::string & GetRootSys()
std::string MakePathRelative(const std::string &path, const std::string &base, bool isBuildingROOT=false)
bool ConvertEnvValueToBool(const std::string &value)
const std::string & GetFallbackRootSys()
const std::string & GetEtcDir()
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...