ATLAS Offline Software
Loading...
Searching...
No Matches
FileHelpers.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
5
6#include "GeoModelKernel/throwExcept.h"
7#include <filesystem>
8#include <algorithm>
9namespace MuonValR4{
10 std::string removeNonAlphaNum(std::string str) {
11 str.erase(std::remove_if(str.begin(),str.end(),
12 [](const unsigned char c){
13 return !std::isalnum(c);
14 }), str.end());
15 return str;
16 }
17 void ensureDirectory(const std::string& path) {
18 const std::string dir = path.substr(0, path.rfind("/"));
19 if (dir.rfind("/") != std::string::npos){
20 ensureDirectory(dir);
21 } else if (dir.empty()) {
22 return;
23 }
24 if (!std::filesystem::is_directory(dir) && !std::filesystem::create_directory(dir)) {
25 THROW_EXCEPTION("Failed to create "<<dir);
26 }
27 }
28}
Lightweight algorithm to read xAOD MDT sim hits and (fast-digitised) drift circles from SG and fill a...
void ensureDirectory(const std::string &path)
Ensures that the subdirectory in the path is created.
std::string removeNonAlphaNum(std::string str)
Removes all non-alpha numerical characters from a string.
DataModel_detail::iterator< DVL > remove_if(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end, Predicate pred)
Specialization of remove_if for DataVector/List.
#define THROW_EXCEPTION(MESSAGE)
Definition throwExcept.h:10