#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 70 of file PathResolver.cxx.
71 #ifdef XAOD_STANDALONE
◆ find_calib_directory()
std::string PathResolver::find_calib_directory |
( |
const std::string & |
logical_file_name | ) |
|
|
static |
Definition at line 236 of file PathResolver.cxx.
238 checkForDev(
asgMsg(), logical_file_name);
242 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 214 of file PathResolver.cxx.
216 checkForDev(
asgMsg(), logical_file_name);
218 if (logical_file_name.starts_with(
"root://")) {
220 std::unique_ptr<TFile> fTmp{TFile::Open(logical_file_name.c_str())};
221 if (!fTmp || fTmp->IsZombie()) {
222 msg(MSG::WARNING) <<
"Could not open " << logical_file_name <<
endmsg;
225 return logical_file_name;
230 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 191 of file PathResolver.cxx.
196 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 204 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 162 of file PathResolver.cxx.
165 #ifndef XAOD_ANALYSIS
166 if (logical_file_name.starts_with(
'/')) {
167 msg(MSG::ERROR) <<
"Use of an absolute file name: " << logical_file_name <<
endmsg;
173 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 181 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 89 of file PathResolver.cxx.
93 TString tmpString(logical_file_name);
94 gSystem->ExpandPathName(tmpString);
100 const std::string searchPath =
std::format(
"./{}{}", path_separator, search_list);
104 std::string_view
path(
r.begin(),
r.end());
105 const bool is_http =
path.starts_with(
"http//");
106 if( (is_http ||
path.starts_with(
"https//")) &&
111 const std::string fileToDownload =
std::format(
"{}://{}/{}", is_http ?
"http" :
"https",
114 const fs::path targetPath = locationToDownloadTo /
file;
116 targetDir.remove_filename();
117 msg(
MSG::DEBUG) <<
"Attempting http download of " << fileToDownload <<
" to " << targetDir <<
endmsg;
119 if (!is_directory(targetDir)) {
121 if(!fs::create_directories(targetDir)) {
122 msg(MSG::ERROR) <<
"Unable to create directories to write file to " << targetDir <<
endmsg;
127 if (!TFile::Cp(fileToDownload.c_str(), targetPath.c_str(),
false)) {
128 msg(MSG::WARNING) <<
"Unable to download file " << fileToDownload <<
endmsg;
135 }
else if (locationToDownloadTo==
".") {
138 std::ofstream ofs(dummyFile);
140 locationToDownloadTo =
path;
152 }
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.