Skip to content

Commit

Permalink
Revert "TRestMetadata: method "SearchFile" can receive additional sea…
Browse files Browse the repository at this point in the history
…rch path"

This reverts commit 24ee325.
  • Loading branch information
jgalan committed Jan 12, 2019
1 parent 74b09fe commit a6ffcc3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
2 changes: 1 addition & 1 deletion source/restcore/inc/TRestMetadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> addonPath = {});
string SearchFile(string filename);

std::string DownloadHttpFile( string remoteFile );

Expand Down
32 changes: 19 additions & 13 deletions source/restcore/src/TRestMetadata.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,6 @@
#include <TSystem.h>
#include "TRestMetadata.h"
#include "RmlUpdateTool.h"
#include "TRestWebFile.h"
#include "v5/TFormula.h"

//implementation of version methods in namespace rest_version
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<string> 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);
}
}
Expand Down

0 comments on commit a6ffcc3

Please sign in to comment.