7 #include "boost/filesystem/path.hpp" 8 #include "boost/filesystem/operations.hpp" 15 namespace bf = boost::filesystem;
20 std::atomic<bool> s_fileLookupDisabled{
false};
26 const std::string PathVariableName(
"CMSSW_SEARCH_PATH");
42 char const*
const var = getenv(envName.c_str());
52 char const*
const var = getenv(envName.c_str());
59 size_t actualSize = path.size() - src.size();
60 assert(path.substr(actualSize, src.size()) == src);
61 return path.substr(0, actualSize);
65 char const*
const var = getenv(envName.c_str());
70 typedef std::vector<std::string> stringvec_t;
72 for(
auto& element : pathElements) {
74 if(!theSearchPath.empty()) theSearchPath +=
":";
75 theSearchPath += element;
91 if (!bf::exists(p))
return false;
93 if (bf::is_directory(p)) {
97 <<
" is a directory, not a file\n";
100 if (bf::is_symlink(bf::symlink_status(p))) {
104 <<
" is a symbolic link, not a file\n";
115 canonicalFilename_(),
118 if (s_fileLookupDisabled) {
129 if (s_fileLookupDisabled) {
141 if (s_fileLookupDisabled) {
211 <<
"Environment Variable " 220 <<
" is not in the local release area " 229 <<
"Environment Variable " 238 <<
" is not in the base release area " 247 <<
"Environment Variable " 256 <<
" is not in the data area " 276 bool oldFormat = (
version != vsn);
286 is >> relname >>
loc;
291 is >> vsn >> relname >>
loc >> canFilename;
298 <<
"Environment Variable " 301 <<
"Trying to read Local file: " << canFilename <<
".\n";
314 <<
"Environment Variable " 336 <<
"Environment Variable " 352 bool oldFormat = (
version != vsn);
362 is >> relname >>
loc;
394 <<
"Environment Variable " 407 static std::string const searchPath = removeSymLinksTokens(PathVariableName);
408 if (searchPath.empty()) {
411 <<
" must be defined\n";
415 static std::string const releaseTop = removeSymLinksSrc(RELEASETOP);
418 static std::string const localTop = removeSymLinksSrc(LOCALTOP);
421 static std::string const dataTop = removeSymLinks(DATATOP);
443 <<
"Relative path must not be empty\n";
447 typedef std::vector<std::string> stringvec_t;
449 for(
auto const& element : pathElements) {
464 <<
"fullPath is empty" 466 <<
"\npath prefix is: " << pathPrefix.string()
472 for (
bf::path br = pathPrefix.branch_path(); !
br.normalize().string().empty();
br =
br.branch_path()) {
488 if (
br == release_) {
510 <<
"edm::FileInPath unable to find file " 512 <<
" anywhere in the search path." 513 <<
"\nThe search path is defined by: " 518 << getenv(PathVariableName.c_str())
519 <<
"\nCurrent directory is: " 520 << bf::initial_path().string()
525 s_fileLookupDisabled =
true;
std::string canonicalFilename_
void write(std::ostream &os) const
void swap(FileInPath &other)
static void disableFileLookup()
Should only be called while the edmWriteConfigs executable runs.
void read(std::istream &is)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
LocationCode location() const
Where was the file found?
std::string relativePath_
FileInPath & operator=(FileInPath const &other)
std::string fullPath() const
void readFromParameterSetBlob(std::istream &is)
std::string relativePath() const
void resolveSymbolicLinks(std::string &fullPath)
std::vector< std::string > tokenize(std::string const &input, std::string const &separator)
breaks the input string into tokens, delimited by the separator