From 2a471846314b4920db3bedeee44fe84b21f90d03 Mon Sep 17 00:00:00 2001 From: LukasChlad <l.chlad@gsi.de> Date: Tue, 22 Aug 2023 17:16:42 +0200 Subject: [PATCH] Automatic insertion of caller function name in CheckOutFileName --- .../production/run_analysis_tree_maker_json_config.C | 9 ++++----- macro/PWG/common/production/run_reco_json_config.C | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/macro/PWG/common/production/run_analysis_tree_maker_json_config.C b/macro/PWG/common/production/run_analysis_tree_maker_json_config.C index 86b8e56b75..5cccd6a476 100644 --- a/macro/PWG/common/production/run_analysis_tree_maker_json_config.C +++ b/macro/PWG/common/production/run_analysis_tree_maker_json_config.C @@ -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; } diff --git a/macro/PWG/common/production/run_reco_json_config.C b/macro/PWG/common/production/run_reco_json_config.C index cd57175dd9..93c645ff73 100644 --- a/macro/PWG/common/production/run_reco_json_config.C +++ b/macro/PWG/common/production/run_reco_json_config.C @@ -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; } -- GitLab