6 #include "boost/filesystem/path.hpp" 7 #include "boost/filesystem/operations.hpp" 14 namespace bf = boost::filesystem;
22 const std::string PathVariableName(
"CMSSW_SEARCH_PATH");
38 char const*
const var = getenv(envName.c_str());
48 char const*
const var = getenv(envName.c_str());
55 size_t actualSize = path.size() - src.size();
56 assert(path.substr(actualSize, src.size()) == src);
57 return path.substr(0, actualSize);
61 char const*
const var = getenv(envName.c_str());
66 typedef std::vector<std::string> stringvec_t;
68 for(
auto& element : pathElements) {
70 if(!theSearchPath.empty()) theSearchPath +=
":";
71 theSearchPath += element;
87 if (!bf::exists(p))
return false;
89 if (bf::is_directory(p)) {
93 <<
" is a directory, not a file\n";
96 if (bf::is_symlink(bf::symlink_status(p))) {
100 <<
" is a symbolic link, not a file\n";
111 canonicalFilename_(),
198 <<
"Environment Variable " 207 <<
" is not in the local release area " 216 <<
"Environment Variable " 225 <<
" is not in the base release area " 234 <<
"Environment Variable " 243 <<
" is not in the data area " 263 bool oldFormat = (
version != vsn);
273 is >> relname >>
loc;
278 is >> vsn >> relname >>
loc >> canFilename;
285 <<
"Environment Variable " 288 <<
"Trying to read Local file: " << canFilename <<
".\n";
301 <<
"Environment Variable " 323 <<
"Environment Variable " 339 bool oldFormat = (
version != vsn);
349 is >> relname >>
loc;
381 <<
"Environment Variable " 394 static std::string const searchPath = removeSymLinksTokens(PathVariableName.c_str());
395 if (searchPath.empty()) {
398 <<
" must be defined\n";
402 static std::string const releaseTop = removeSymLinksSrc(RELEASETOP.c_str());
405 static std::string const localTop = removeSymLinksSrc(LOCALTOP.c_str());
408 static std::string const dataTop = removeSymLinks(DATATOP.c_str());
411 if (releaseTop_.empty()) {
418 if (releaseTop_ == localTop_) {
430 <<
"Relative path must not be empty\n";
434 typedef std::vector<std::string> stringvec_t;
436 for(
auto const& element : pathElements) {
451 <<
"fullPath is empty" 453 <<
"\npath prefix is: " << pathPrefix.string()
459 for (
bf::path br = pathPrefix.branch_path(); !
br.normalize().string().empty();
br =
br.branch_path()) {
475 if (
br == release_) {
497 <<
"edm::FileInPath unable to find file " 499 <<
" anywhere in the search path." 500 <<
"\nThe search path is defined by: " 505 << getenv(PathVariableName.c_str())
506 <<
"\nCurrent directory is: " 507 << bf::initial_path().string()
std::string canonicalFilename_
void write(std::ostream &os) const
void swap(FileInPath &other)
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