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 = std::getenv(envName.c_str());
51 char const*
const var = std::getenv(envName.c_str());
58 size_t actualSize =
path.size() -
src.size();
60 return path.substr(0, actualSize);
64 char const*
const var = std::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";
107 if (s_fileLookupDisabled) {
114 if (s_fileLookupDisabled) {
122 if (s_fileLookupDisabled) {
133 : relativePath_(
other.relativePath_),
134 canonicalFilename_(
other.canonicalFilename_),
135 location_(
other.location_),
136 localTop_(
other.localTop_),
137 releaseTop_(
other.releaseTop_),
138 dataTop_(
other.dataTop_),
139 searchPath_(
other.searchPath_) {}
214 bool oldFormat = (
version != vsn);
224 is >> relname >> loc;
225 location_ = static_cast<FileInPath::LocationCode>(loc);
230 is >> vsn >> relname >> loc >> canFilename;
238 <<
"Trying to read Local file: " << canFilename <<
".\n";
282 bool oldFormat = (
version != vsn);
292 is >> relname >> loc;
293 location_ = static_cast<FileInPath::LocationCode>(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: " << std::getenv(PathVariableName.c_str())
433 <<
"\nCurrent directory is: " << bf::initial_path().string() <<
"\n";