Skip to content

Commit

Permalink
include _t<n> suffix in check for existing files (#198)
Browse files Browse the repository at this point in the history
* include _t<n> suffix in check for existing files

* terminate run as fast as possible if any output file exists
  • Loading branch information
ManuelHu authored Dec 17, 2024
1 parent aa79b22 commit 68276a9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/RMGRunAction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,13 @@ std::pair<fs::path, fs::path> RMGRunAction::BuildOutputFile() const {

// TODO: realpath
auto path = fs::path(manager->GetOutputFileName());
if (fs::exists(path) && !manager->GetOutputOverwriteFiles()) {
RMGLog::Out(RMGLog::fatal, "Output file ", path.string(), " does already exists.");
auto path_for_overwrite =
fs::path(G4Analysis::GetTnFileName(path.string(), path.extension().string()));
if (fs::exists(path_for_overwrite) && !manager->GetOutputOverwriteFiles()) {
RMGLog::Out(RMGLog::error, "Output file ", path_for_overwrite.string(), " does already exists.");
// need to abort here (and not use ::fatal), as Geant4 is not prepared to take exceptions at
// this stage. also, there is no clean way to abort an run before the run started.
std::abort();
}

auto ext = path.extension();
Expand Down

0 comments on commit 68276a9

Please sign in to comment.