21#include <RConfigure.h>
36namespace FoundationUtils {
39 char fixedLength[1024];
40 char *currWorkDir = fixedLength;
42 char *result = currWorkDir;
47 if (fixedLength != currWorkDir) {
50 currWorkDir =
new char[len];
53 result = ::_getcwd(currWorkDir, len);
55 result = getcwd(currWorkDir, len);
57 }
while (result == 0 && errno == ERANGE);
59 std::string
output = currWorkDir;
66 if (fixedLength != currWorkDir) {
72std::string
MakePathRelative(
const std::string &path,
const std::string &base,
bool isBuildingROOT )
74 std::string result(path);
76 const char *currWorkDir = base.c_str();
77 size_t lenCurrWorkDir = strlen(currWorkDir);
78 if (result.substr(0, lenCurrWorkDir) == currWorkDir) {
82 result.erase(0, lenCurrWorkDir);
88 int posInc = result.find(
"/inc/");
90 result = result.substr(posInc + 5, -1);
98 std::replace(Path.begin(), Path.end(),
'\\',
'/');
102 static std::string fallback;
103 if (!fallback.empty())
106 static char lpFilename[_MAX_PATH];
107 if (::GetModuleFileNameA(
110 sizeof(lpFilename))) {
111 auto parent_path = [](std::string path) {
112 return path.substr(0, path.find_last_of(
"/\\"));
114 fallback = parent_path(parent_path(lpFilename));
120 fallback =
"/usr/local/root";
126static bool IgnorePrefix() {
127 static bool ignorePrefix = ::getenv(
"ROOTIGNOREPREFIX");
134 if (!IgnorePrefix()) {
135 const static std::string rootsys = ROOTPREFIX;
139 static std::string rootsys;
140 if (rootsys.empty()) {
141 if (
const char* envValue = ::getenv(
"ROOTSYS")) {
156 if (!IgnorePrefix()) {
157 const static std::string rootincdir = ROOTINCDIR;
161 static std::string rootincdir;
162 if (rootincdir.empty()) {
164 rootincdir =
GetRootSys() + sep +
"include" + sep;
171 if (!IgnorePrefix()) {
172 const static std::string rootetcdir = ROOTETCDIR;
177 const static std::string rootetcdir =
183 std::transform(s.begin(), s.end(), s.begin(),
184 [](
unsigned char c){ return std::tolower(c); });
The file contains utilities which are foundational and could be used across the core component of ROO...
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...
static void output(int code)