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_) {}
212 bool oldFormat = (
version != vsn);
222 is >> relname >> loc;
228 is >> vsn >> relname >> loc >> canFilename;
236 <<
"Trying to read Local file: " << canFilename <<
".\n";
280 bool oldFormat = (
version != vsn);
290 is >> relname >> loc;
331 static std::string const s_searchPath = removeSymLinksTokens(PathVariableName);
342 static std::string const releaseTop = removeSymLinksSrc(RELEASETOP);
345 static std::string const localTop = removeSymLinksSrc(LOCALTOP);
348 static std::string const dataTop = removeSymLinks(DATATOP);
372 typedef std::vector<std::string> stringvec_t;
374 for (
auto const& element : pathElements) {
389 <<
"fullPath is empty" 390 <<
"\nrelativePath() is: " <<
relativePath_ <<
"\npath prefix is: " << pathPrefix.string() <<
'\n';
396 !std::filesystem::weakly_canonical(
br).string().empty();
397 br =
br.parent_path()) {
412 if (
br == release_) {
434 <<
"edm::FileInPath unable to find file " <<
relativePath_ <<
" anywhere in the search path." 435 <<
"\nThe search path is defined by: " << PathVariableName <<
"\n${" << PathVariableName
436 <<
"} is: " << std::getenv(PathVariableName.c_str())
437 <<
"\nCurrent directory is: " << std::filesystem::current_path().string() <<
"\n";
445 for (
auto const& element : pathElements) {
452 if (locateFile(pathPrefix, iFileName)) {
454 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