7 #include "boost/filesystem/path.hpp" 8 #include "boost/filesystem/operations.hpp" 15 namespace bf = boost::filesystem;
19 std::atomic<bool> s_fileLookupDisabled{
false};
25 const std::string PathVariableName(
"CMSSW_SEARCH_PATH");
41 char const*
const var = getenv(envName.c_str());
51 char const*
const var = getenv(envName.c_str());
58 size_t actualSize = path.size() - src.size();
59 assert(path.substr(actualSize, src.size()) == src);
60 return path.substr(0, actualSize);
64 char const*
const var = getenv(envName.c_str());
69 typedef std::vector<std::string> stringvec_t;
71 for (
auto& element : pathElements) {
73 if (!theSearchPath.empty())
75 theSearchPath += element;
92 if (bf::is_directory(p)) {
96 if (bf::is_symlink(bf::symlink_status(p))) {
98 <<
"Path " << p.string() <<
" is a symbolic link, not a file\n";
106 FileInPath::FileInPath() : relativePath_(), canonicalFilename_(), location_(
Unknown) {
107 if (s_fileLookupDisabled) {
114 if (s_fileLookupDisabled) {
122 if (s_fileLookupDisabled) {
214 bool oldFormat = (
version != vsn);
224 is >> relname >>
loc;
230 is >> vsn >> relname >>
loc >> canFilename;
238 <<
"Trying to read Local file: " << canFilename <<
".\n";
282 bool oldFormat = (
version != vsn);
292 is >> relname >>
loc;
334 static std::string const searchPath = removeSymLinksTokens(PathVariableName);
335 if (searchPath.empty()) {
340 static std::string const releaseTop = removeSymLinksSrc(RELEASETOP);
343 static std::string const localTop = removeSymLinksSrc(LOCALTOP);
346 static std::string const dataTop = removeSymLinks(DATATOP);
370 typedef std::vector<std::string> stringvec_t;
372 for (
auto const& element : pathElements) {
387 <<
"fullPath is empty" 388 <<
"\nrelativePath() is: " <<
relativePath_ <<
"\npath prefix is: " << pathPrefix.string() <<
'\n';
393 for (
bf::path br = pathPrefix.branch_path(); !
br.normalize().string().empty();
br =
br.branch_path()) {
408 if (
br == release_) {
430 <<
"edm::FileInPath unable to find file " <<
relativePath_ <<
" anywhere in the search path." 431 <<
"\nThe search path is defined by: " << PathVariableName <<
"\n${" << PathVariableName
432 <<
"} is: " << getenv(PathVariableName.c_str()) <<
"\nCurrent directory is: " << bf::initial_path().string()
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