17 std::atomic<bool> s_fileLookupDisabled{
false};
23 const std::string PathVariableName(
"CMSSW_SEARCH_PATH");
39 char const*
const var = std::getenv(envName.c_str());
49 char const*
const var = std::getenv(envName.c_str());
56 size_t actualSize =
path.size() -
src.size();
58 return path.substr(0, actualSize);
62 char const*
const var = std::getenv(envName.c_str());
67 typedef std::vector<std::string> stringvec_t;
69 for (
auto& element : pathElements) {
71 if (!theSearchPath.empty())
73 theSearchPath += element;
87 if (!std::filesystem::exists(
p))
90 if (std::filesystem::is_directory(
p)) {
94 if (std::filesystem::is_symlink(std::filesystem::symlink_status(
p))) {
96 <<
"Path " <<
p.string() <<
" is a symbolic link, not a file\n";
105 if (s_fileLookupDisabled) {
112 if (s_fileLookupDisabled) {
120 if (s_fileLookupDisabled) {
131 : relativePath_(
other.relativePath_),
132 canonicalFilename_(
other.canonicalFilename_),
133 location_(
other.location_),
134 localTop_(
other.localTop_),
135 releaseTop_(
other.releaseTop_),
136 dataTop_(
other.dataTop_),
137 searchPath_(
other.searchPath_) {}
216 bool oldFormat = (
version != vsn);
226 is >> relname >> loc;
230 }
else if (relname ==
"@") {
235 is >> vsn >> relname >> loc >> canFilename;
243 <<
"Trying to read Local file: " << canFilename <<
".\n";
287 bool oldFormat = (
version != vsn);
297 is >> relname >> loc;
301 }
else if (relname ==
"@") {
341 static std::string const s_searchPath = removeSymLinksTokens(PathVariableName);
352 static std::string const releaseTop = removeSymLinksSrc(RELEASETOP);
355 static std::string const localTop = removeSymLinksSrc(LOCALTOP);
358 static std::string const dataTop = removeSymLinks(DATATOP);
382 typedef std::vector<std::string> stringvec_t;
384 for (
auto const& element : pathElements) {
399 <<
"fullPath is empty" 400 <<
"\nrelativePath() is: " <<
relativePath_ <<
"\npath prefix is: " << pathPrefix.string() <<
'\n';
406 !std::filesystem::weakly_canonical(
br).string().empty();
407 br =
br.parent_path()) {
422 if (
br == release_) {
444 <<
"edm::FileInPath unable to find file " <<
relativePath_ <<
" anywhere in the search path." 445 <<
"\nThe search path is defined by: " << PathVariableName <<
"\n${" << PathVariableName
446 <<
"} is: " << std::getenv(PathVariableName.c_str())
447 <<
"\nCurrent directory is: " << std::filesystem::current_path().string() <<
"\n";
455 for (
auto const& element : pathElements) {
462 if (locateFile(pathPrefix, iFileName)) {
464 return std::filesystem::absolute(pathPrefix / iFileName).string();
std::string canonicalFilename_
void swap(FileInPath &other)
std::string fullPath() const
static void disableFileLookup()
Should only be called while the edmWriteConfigs executable runs.
void swap(Association< C > &lhs, Association< C > &rhs)
void read(std::istream &is)
static std::string const & searchPath()
LocationCode location() const
Where was the file found?
std::vector< std::string > tokenize(std::string const &input, std::string const &separator)
breaks the input string into tokens, delimited by the separator
std::string relativePath_
static std::string findFile(std::string const &)
FileInPath & operator=(FileInPath const &other)
void readFromParameterSetBlob(std::istream &is)
std::string relativePath() const
void resolveSymbolicLinks(std::string &fullPath)
void write(std::ostream &os) const