#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 129 of file PathResolver.cxx.
130 #ifdef XAOD_STANDALONE
135 #ifndef XAOD_ANALYSIS
◆ find_calib_directory()
| std::string PathResolver::find_calib_directory |
( |
const std::string & |
logical_file_name | ) |
|
|
static |
Definition at line 295 of file PathResolver.cxx.
297 checkForDev(
asgMsg(), logical_file_name);
301 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 273 of file PathResolver.cxx.
275 checkForDev(
asgMsg(), logical_file_name);
277 if (logical_file_name.starts_with(
"root://")) {
279 std::unique_ptr<TFile> fTmp{TFile::Open(logical_file_name.c_str())};
280 if (!fTmp || fTmp->IsZombie()) {
281 msg(MSG::WARNING) <<
"Could not open " << logical_file_name <<
endmsg;
284 return logical_file_name;
289 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 250 of file PathResolver.cxx.
255 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 263 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 221 of file PathResolver.cxx.
224 #ifndef XAOD_ANALYSIS
225 if (logical_file_name.starts_with(
'/')) {
226 msg(MSG::ERROR) <<
"Use of an absolute file name: " << logical_file_name <<
endmsg;
232 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 240 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 148 of file PathResolver.cxx.
152 TString tmpString(logical_file_name);
153 gSystem->ExpandPathName(tmpString);
156 fs::path locationToDownloadTo =
".";
159 const std::string searchPath =
std::format(
"./{}{}", path_separator, search_list);
163 std::string_view
path(
r.begin(),
r.end());
164 const bool is_http =
path.starts_with(
"http//");
165 if( (is_http ||
path.starts_with(
"https//")) &&
170 const std::string fileToDownload =
std::format(
"{}://{}/{}", is_http ?
"http" :
"https",
173 const fs::path targetPath = locationToDownloadTo /
file;
175 targetDir.remove_filename();
176 msg(
MSG::DEBUG) <<
"Attempting http download of " << fileToDownload <<
" to " << targetDir <<
endmsg;
178 if (!is_directory(targetDir)) {
180 if(!fs::create_directories(targetDir)) {
181 msg(MSG::ERROR) <<
"Unable to create directories to write file to " << targetDir <<
endmsg;
186 if (!download_file(fileToDownload, targetPath,
asgMsg())) {
187 msg(MSG::WARNING) <<
"Unable to download file " << fileToDownload <<
endmsg;
194 }
else if (locationToDownloadTo==
".") {
197 std::ofstream ofs(dummyFile);
199 locationToDownloadTo =
path;
211 }
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.