#include <PathResolver.h>
|
static bool | PR_find (const std::string &logical_file_name, const std::string &search_list, std::filesystem::file_type file_type, std::string &result) |
| Main private search method used by all public methods. More...
|
|
static bool | msgLvl (const MSG::Level lvl) |
|
static MsgStream & | msg () |
|
static MsgStream & | msg (const MSG::Level lvl) |
|
static asg::AsgMessaging & | asgMsg () |
|
|
static std::atomic< MSG::Level > | m_level {MSG::INFO} |
|
Definition at line 15 of file PathResolver.h.
◆ PathResolver()
PathResolver::PathResolver |
( |
| ) |
|
|
default |
◆ asgMsg()
In AnalysisBase this method is not available
Definition at line 79 of file PathResolver.cxx.
80 #ifdef XAOD_STANDALONE
◆ find_calib_directory()
std::string PathResolver::find_calib_directory |
( |
const std::string & |
logical_file_name | ) |
|
|
static |
Definition at line 257 of file PathResolver.cxx.
259 checkForDev(
asgMsg(), logical_file_name);
263 msg(MSG::WARNING) <<
"Could not locate " << logical_file_name <<
endmsg;
◆ find_calib_file()
std::string PathResolver::find_calib_file |
( |
const std::string & |
logical_file_name | ) |
|
|
static |
Definition at line 235 of file PathResolver.cxx.
237 checkForDev(
asgMsg(), logical_file_name);
239 if (logical_file_name.starts_with(
"root://")) {
241 std::unique_ptr<TFile> fTmp{TFile::Open(logical_file_name.c_str())};
242 if (!fTmp || fTmp->IsZombie()) {
243 msg(MSG::WARNING) <<
"Could not open " << logical_file_name <<
endmsg;
246 return logical_file_name;
251 msg(MSG::WARNING) <<
"Could not locate " << logical_file_name <<
endmsg;
◆ find_directory()
std::string PathResolver::find_directory |
( |
const std::string & |
logical_file_name, |
|
|
const std::string & |
search_path |
|
) |
| |
|
static |
logical_file_name
the name of the directory to locate in the search path
search_path
the name of a path-like environment variable
- Returns
- the physical name of the located directory or empty string if not found
Definition at line 212 of file PathResolver.cxx.
217 msg(MSG::ERROR) << search_path <<
" environment variable not defined!" <<
endmsg;
◆ find_directory_from_list()
std::string PathResolver::find_directory_from_list |
( |
const std::string & |
logical_file_name, |
|
|
const std::string & |
search_list |
|
) |
| |
|
static |
logical_file_name
the name of the directory to locate in the search path
search_list
the prioritized list of possible locations separated by the usual path separator
- Returns
- the physical name of the located directory or empty string if not found
Definition at line 225 of file PathResolver.cxx.
◆ find_file()
std::string PathResolver::find_file |
( |
const std::string & |
logical_file_name, |
|
|
const std::string & |
search_path |
|
) |
| |
|
static |
logical_file_name
the name of the file to locate in the search path
search_path
the name of a path-like environment variable
- Returns
- the physical name of the located file or empty string if not found
Definition at line 183 of file PathResolver.cxx.
186 #ifndef XAOD_ANALYSIS
187 if (logical_file_name.starts_with(
'/')) {
188 msg(MSG::ERROR) <<
"Use of an absolute file name: " << logical_file_name <<
endmsg;
194 msg(MSG::ERROR) << search_path <<
" environment variable not defined!" <<
endmsg;
◆ find_file_from_list()
std::string PathResolver::find_file_from_list |
( |
const std::string & |
logical_file_name, |
|
|
const std::string & |
search_list |
|
) |
| |
|
static |
logical_file_name
the name of the file to locate in the search path
search_list
the prioritized list of possible locations separated by the usual path separator
- Returns
- the physical name of the located file or empty string if not found
Definition at line 202 of file PathResolver.cxx.
◆ FindCalibDirectory()
static std::string PathResolver::FindCalibDirectory |
( |
const std::string & |
logical_file_name | ) |
|
|
inlinestatic |
◆ FindCalibFile()
static std::string PathResolver::FindCalibFile |
( |
const std::string & |
logical_file_name | ) |
|
|
inlinestatic |
◆ msg() [1/2]
static MsgStream& PathResolver::msg |
( |
| ) |
|
|
inlinestaticprivate |
◆ msg() [2/2]
static MsgStream& PathResolver::msg |
( |
const MSG::Level |
lvl | ) |
|
|
inlinestaticprivate |
◆ msgLvl()
static bool PathResolver::msgLvl |
( |
const MSG::Level |
lvl | ) |
|
|
inlinestaticprivate |
◆ PR_find()
bool PathResolver::PR_find |
( |
const std::string & |
logical_file_name, |
|
|
const std::string & |
search_list, |
|
|
std::filesystem::file_type |
file_type, |
|
|
std::string & |
result |
|
) |
| |
|
staticprivate |
Main private search method used by all public methods.
Definition at line 98 of file PathResolver.cxx.
102 TString tmpString(logical_file_name);
103 gSystem->ExpandPathName(tmpString);
106 fs::path locationToDownloadTo =
".";
109 const std::string searchPath =
std::format(
"./{}{}", path_separator, search_list);
113 std::string_view
path(
r.begin(),
r.end());
114 const bool is_http =
path.starts_with(
"http//");
115 if( (is_http ||
path.starts_with(
"https//")) &&
120 const std::string fileToDownload =
std::format(
"{}://{}/{}", is_http ?
"http" :
"https",
123 const fs::path targetPath = locationToDownloadTo /
file;
125 targetDir.remove_filename();
126 msg(
MSG::DEBUG) <<
"Attempting http download of " << fileToDownload <<
" to " << targetDir <<
endmsg;
128 if (!is_directory(targetDir)) {
130 if(!fs::create_directories(targetDir)) {
131 msg(MSG::ERROR) <<
"Unable to create directories to write file to " << targetDir <<
endmsg;
136 if (!TFile::Cp(fileToDownload.c_str(), targetPath.c_str(),
false)) {
139 <<
" with ROOT, falling back to command line tools"
141 if (download_with_curl(fileToDownload, targetPath)) {
146 msg(MSG::WARNING) <<
"Unable to download file "
156 }
else if (locationToDownloadTo==
".") {
159 std::ofstream ofs(dummyFile);
161 locationToDownloadTo =
path;
173 }
catch (
const fs::filesystem_error&) {
◆ SetOutputLevel()
static void PathResolver::SetOutputLevel |
( |
int |
lvl | ) |
|
|
inlinestatic |
◆ setOutputLevel()
void PathResolver::setOutputLevel |
( |
MSG::Level |
level | ) |
|
|
static |
◆ m_level
std::atomic<MSG::Level> PathResolver::m_level {MSG::INFO} |
|
inlinestaticprivate |
The documentation for this class was generated from the following files:
static bool PR_find(const std::string &logical_file_name, const std::string &search_list, std::filesystem::file_type file_type, std::string &result)
Main private search method used by all public methods.