Skip to content
Snippets Groups Projects
Commit 2a471846 authored by Lukas Chlad's avatar Lukas Chlad
Browse files

Automatic insertion of caller function name in CheckOutFileName

parent 640b4962
No related branches found
No related tags found
1 merge request!1295Improvements to PWG_common_production
......@@ -3,12 +3,11 @@
Authors: Viktor Klochkov, Frederic Linz [committer] */
// ----- Check output file name -------------------------------------------
bool CheckOutFileName(TString fileName, Bool_t overwrite)
bool CheckOutFileName(TString fileName, Bool_t overwrite, const char* caller = __builtin_FUNCTION())
{
string fName = "run_analysis_tree_maker_json_config";
// --- Protect against overwriting an existing file
if ((!gSystem->AccessPathName(fileName.Data())) && (!overwrite)) {
cout << fName << ": output file " << fileName << " already exists!";
std::cout << caller << ": output file " << fileName << " already exists!" << std::endl;
return false;
}
......@@ -17,11 +16,11 @@ bool CheckOutFileName(TString fileName, Bool_t overwrite)
if (gSystem->AccessPathName(directory)) {
Int_t success = gSystem->mkdir(directory, kTRUE);
if (success == -1) {
cout << fName << ": output directory " << directory << " does not exist and cannot be created!";
std::cout << caller << ": output directory " << directory << " does not exist and cannot be created!" << std::endl;
return false;
}
else
cout << fName << ": created directory " << directory;
std::cout << caller << ": created directory " << directory << std::endl;
}
return true;
}
......
......@@ -92,12 +92,11 @@
**/
// ----- Check output file name -------------------------------------------
bool CheckOutFileName(TString fileName, Bool_t overwrite)
bool CheckOutFileName(TString fileName, Bool_t overwrite, const char* caller = __builtin_FUNCTION())
{
string fName = "run_reco_json_config";
// --- Protect against overwriting an existing file
if ((!gSystem->AccessPathName(fileName.Data())) && (!overwrite)) {
cout << fName << ": output file " << fileName << " already exists!";
std::cout << caller << ": output file " << fileName << " already exists!" << std::endl;
return false;
}
......@@ -106,11 +105,11 @@ bool CheckOutFileName(TString fileName, Bool_t overwrite)
if (gSystem->AccessPathName(directory)) {
Int_t success = gSystem->mkdir(directory, kTRUE);
if (success == -1) {
cout << fName << ": output directory " << directory << " does not exist and cannot be created!";
std::cout << caller << ": output directory " << directory << " does not exist and cannot be created!" << std::endl;
return false;
}
else
cout << fName << ": created directory " << directory;
std::cout << caller << ": created directory " << directory << std::endl;
}
return true;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment