Main private search method used by all public methods.
148 {
149
150
151 TString tmpString(logical_file_name);
152 gSystem->ExpandPathName(tmpString);
153
154 fs::path
file(tmpString.Data());
155 fs::path locationToDownloadTo = ".";
156
157
158 const std::string searchPath = std::format("./{}{}", path_separator, search_list);
159
160
161 for (
const auto r : searchPath | std::views::split(path_separator)) {
162 std::string_view
path(
r.begin(),
r.end());
163 const bool is_http =
path.starts_with(
"http//");
164 if( (is_http ||
path.starts_with(
"https//")) &&
165 file_type==fs::file_type::regular && std::getenv("PATHRESOLVER_ALLOWHTTPDOWNLOAD") ) {
166
167
168
169 const std::string fileToDownload = std::format("{}://{}/{}", is_http ? "http" : "https",
171
172 const fs::path targetPath = locationToDownloadTo /
file;
173 fs::path targetDir = targetPath;
174 targetDir.remove_filename();
175 if (
msgLvl(MSG::DEBUG))
msg(MSG::DEBUG) <<
"Attempting http download of " << fileToDownload <<
" to " << targetDir <<
endmsg;
176
177 if (!is_directory(targetDir)) {
178 if (
msgLvl(MSG::DEBUG))
msg(MSG::DEBUG) <<
"Creating directory " << targetDir <<
endmsg;
179 if(!fs::create_directories(targetDir)) {
180 msg(MSG::ERROR) <<
"Unable to create directories to write file to " << targetDir <<
endmsg;
181 return false;
182 }
183 }
184
185 if (!download_file(fileToDownload, targetPath,
asgMsg())) {
186 msg(MSG::WARNING) <<
"Unable to download file " << fileToDownload <<
endmsg;
187 } else {
188 if (
msgLvl(MSG::DEBUG))
msg(MSG::DEBUG) <<
"Successfully downloaded " << fileToDownload <<
endmsg;
190 return true;
191 }
192
193 } else if (locationToDownloadTo==".") {
194
195 fs::path dummyFile = fs::path(path) / "._pathresolver_dummy";
196 std::ofstream ofs(dummyFile);
197 if (ofs.is_open()) {
198 locationToDownloadTo =
path;
199 ofs.close();
200 fs::remove(dummyFile);
201 }
202 }
203
205 try {
206 if (fs::status(fp).
type() == file_type) {
207 result = fs::absolute(fp).string();
208 return true;
209 }
210 } catch (const fs::filesystem_error&) {
211
212 }
213
214 }
215
216 return false;
217}
static bool msgLvl(const MSG::Level lvl)
path
python interpreter configuration --------------------------------------—