10 #include "boost/algorithm/string.hpp" 11 #include "boost/filesystem.hpp" 17 namespace fs = boost::filesystem;
21 fs::path Env::cwd_ = fs::current_path();
29 index = path.rfind(
"/");
30 base = path.substr(0, index);
40 if (instdir_.length() > 0)
43 if (instdir.length() > 0)
44 instdir =
"/home/stomps/.local";
46 instdir = fs::path(instdir).parent_path().parent_path().string();
47 if (!fs::exists(instdir))
48 instdir =
"/home/stomps/.local";
49 if (std::strlen(instdir.c_str()) < instdir.length()) {
53 instdir.resize(std::strlen(instdir.c_str()));
60 std::string blddir =
"/home/stomps/dev-cyclus/cyclus/_tmp_build";
61 if (std::strlen(blddir.c_str()) < blddir.length()) {
65 blddir.resize(std::strlen(blddir.c_str()));
66 std::cout <<
"resized builddir " << blddir <<
"\n";
72 char* pVar = getenv(varname.c_str());
97 if (p !=
"" && fs::exists(p)) {
106 p =
GetBuildPath() +
"/share/cyclus/cyclus_nuc_data.h5";
111 throw IOError(
"cyclus_nuc_data.h5 not found in " 112 " environment variable CYCLUS_NUC_DATA or " 119 if (p !=
"" && fs::exists(p)) {
128 p =
GetBuildPath() +
"/share/cyclus/cyclus-flat.rng.in";
132 throw IOError(
"cyclus.rng.in not found in " 133 " environment variable CYCLUS_RNG_SCHEMA or " 145 throw IOError(
"cyclus-flat.rng.in not found in " 146 " environment variable CYCLUS_RNG_SCHEMA or " 154 std::vector<std::string> strs;
162 char* envvar = getenv(
"ALLOW_MILPS");
163 if (envvar == NULL) {
168 std::transform(s.begin(), s.end(), s.begin(), ::tolower);
169 return !(s ==
"" || s ==
"f" || s ==
"false" || s ==
"0");
174 std::cout << __FILE__ << ":" << __LINE__ << ": "#X" = " << X << "\n" 181 boost::system::error_code errc;
184 for (
int i = 0; i < strs.size(); ++i) {
185 fs::path full = fs::path(strs[i]) / path;
186 if (fs::exists(full, errc)) {
187 return full.string();
192 if (!pymod.empty()) {
196 throw IOError(
"No module found for path " + path);
static const std::string GetBuildPath()
The relative path to the root build directory (containing bin, lib, etc.)
static const bool allow_milps()
std::string PyFindModule(std::string lib)
Finds a Python module and returns its filename.
static const std::vector< std::string > cyclus_path()
static std::string FindModule(std::string path)
Returns the full path to a module by searching through default install and CYCLUS_PATH directories...
static std::string GetEnv(std::string var)
Method to check the existence of and return an environment variable.
for failed reading/writing to files, network connections, etc..
static std::string PathBase(std::string path)
the path basis
static const std::string rng_schema(bool flat=false)
Returns the current rng schema.
static const std::string nuc_data()
Code providing rudimentary logging capability for the Cyclus core.
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or.org/Osi/browser/trunk.
static const std::string GetInstallPath()
The relative path to the root install directory (containing bin, lib, etc.) This first checks the pat...
static const std::string PathDelimiter()
static const std::string EnvDelimiter()
std::vector< std::string > split(const std::string &s, char delim)