From a6ffcc35eba8169a599ed7beacf6aa95f2bbc182 Mon Sep 17 00:00:00 2001 From: jgalan Date: Sat, 12 Jan 2019 13:18:26 +0100 Subject: [PATCH] Revert "TRestMetadata: method "SearchFile" can receive additional search path" This reverts commit 24ee325af635f87bf18104262352d4ad6c1f6c51. --- source/restcore/inc/TRestMetadata.h | 2 +- source/restcore/src/TRestMetadata.cxx | 32 ++++++++++++++++----------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/source/restcore/inc/TRestMetadata.h b/source/restcore/inc/TRestMetadata.h index a35459f5a..8ad79ccc9 100644 --- a/source/restcore/inc/TRestMetadata.h +++ b/source/restcore/inc/TRestMetadata.h @@ -120,7 +120,7 @@ class TRestMetadata :public TNamed { std::string ReplaceEnvironmentalVariables(const std::string buffer); void SetEnv(string name, string value, bool overwriteexisting); void ClearEnv() { fElementEnv.clear(); } - string SearchFile(string filename, vector addonPath = {}); + string SearchFile(string filename); std::string DownloadHttpFile( string remoteFile ); diff --git a/source/restcore/src/TRestMetadata.cxx b/source/restcore/src/TRestMetadata.cxx index 41c8edc7f..5b06ae89e 100644 --- a/source/restcore/src/TRestMetadata.cxx +++ b/source/restcore/src/TRestMetadata.cxx @@ -399,7 +399,6 @@ #include #include "TRestMetadata.h" #include "RmlUpdateTool.h" -#include "TRestWebFile.h" #include "v5/TFormula.h" //implementation of version methods in namespace rest_version @@ -886,17 +885,26 @@ void TRestMetadata::ExpandIncludeFile(TiXmlElement * e) debug << "-- Debug : Entering ... " << __PRETTY_FUNCTION__ << endl; ReplaceElementAttributes(e); + const char* _filetmp = e->Attribute("file"); - const char*_filename= e->Attribute("file"); - if (_filename == NULL) { error << "this cannot happen" << endl; exit(1); } - string filename = _filename; + if (_filetmp == NULL && (string) e->Value() == "TRestGas" ) + _filetmp = "server"; - if (filename == "" || filename == "server") { - string webFileKey = (string)e->Value(); - filename = GetRESTWebFiles(webFileKey).Download(); - } + if (_filetmp == NULL)return; + string _filename = _filetmp; + + // For the moment we only expect to have the gasFiles localed remotely. + // I keep "server" keyword to be coherent with the one used in TRestGas constructor + if( _filename == "server" && (string) e->Value() == "TRestGas" ) + _filename = (string) gasesFile; + + + debug << "-- Debug : filename to expand : " << _filename << endl; - filename = SearchFile(filename); + if( REST_StringHelper::isURL( _filename ) ) + _filename = DownloadHttpFile( _filename ); + + string filename = SearchFile(_filename); if (filename == "") { warning << "REST WARNING(expand include file): Include file \"" << _filename << "\" does not exist!" << endl; warning << endl; @@ -1967,17 +1975,15 @@ void TRestMetadata::SetEnv(string name, string value, bool overwriteexisting) /// /// Return blank string if file not found, return directly filename if found in current /// directory, return full name (path+name) if found in "searchPath". -string TRestMetadata::SearchFile(string filename, vector addonPath) { +string TRestMetadata::SearchFile(string filename) { if (fileExists(filename)) { return filename; } else { + auto pathstring = GetSearchPath(); auto paths = Spilt((string)pathstring, ":"); - if (addonPath.size() != 0) { - paths.insert(paths.begin(), addonPath.begin(), addonPath.end()); - } return SearchFileInPath(paths, filename); } }