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) {
199 bool oldFormat = (
version != vsn);
209 is >> relname >>
loc;
213 }
else if (relname ==
"@") {
218 is >> vsn >> relname >>
loc >> canFilename;
226 <<
"Trying to read Local file: " << canFilename <<
".\n";
270 bool oldFormat = (
version != vsn);
280 is >> relname >>
loc;
284 }
else if (relname ==
"@") {
324 static std::string const s_searchPath = removeSymLinksTokens(PathVariableName);
335 static std::string const releaseTop = removeSymLinksSrc(RELEASETOP);
338 static std::string const localTop = removeSymLinksSrc(LOCALTOP);
341 static std::string const dataTop = removeSymLinks(DATATOP);
365 typedef std::vector<std::string> stringvec_t;
367 for (
auto const& element : pathElements) {
382 <<
"fullPath is empty" 383 <<
"\nrelativePath() is: " <<
relativePath_ <<
"\npath prefix is: " << pathPrefix.string() <<
'\n';
389 !std::filesystem::weakly_canonical(
br).string().empty();
390 br =
br.parent_path()) {
405 if (
br == release_) {
427 <<
"edm::FileInPath unable to find file " <<
relativePath_ <<
" anywhere in the search path." 428 <<
"\nThe search path is defined by: " << PathVariableName <<
"\n${" << PathVariableName
429 <<
"} is: " << std::getenv(PathVariableName.c_str())
430 <<
"\nCurrent directory is: " << std::filesystem::current_path().string() <<
"\n";
438 for (
auto const& element : pathElements) {
445 if (locateFile(pathPrefix, iFileName)) {
447 return std::filesystem::absolute(pathPrefix / iFileName).string();
std::string canonicalFilename_
void swap(FileInPath &other)
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?
const std::string & relativePath() const
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 &)
void readFromParameterSetBlob(std::istream &is)
const std::string & fullPath() const
void resolveSymbolicLinks(std::string &fullPath)
void write(std::ostream &os) const