From a7a109b4e9ccd324ae85e03664a8e8d1c63ae600 Mon Sep 17 00:00:00 2001 From: Maximilian Reininghaus <maximilian.reininghaus@tu-dortmund.de> Date: Wed, 22 Apr 2020 16:47:01 +0200 Subject: [PATCH] got rid of std::filesystem as it is not available with g++ 7 --- Framework/Utilities/CorsikaData.cc | 14 ++++++++++++-- Framework/Utilities/CorsikaData.h | 4 ++-- Processes/UrQMD/UrQMD.cc | 6 +++--- Processes/UrQMD/UrQMD.h | 7 +++---- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/Framework/Utilities/CorsikaData.cc b/Framework/Utilities/CorsikaData.cc index 1d30f5132..5b0c1efc9 100644 --- a/Framework/Utilities/CorsikaData.cc +++ b/Framework/Utilities/CorsikaData.cc @@ -1,12 +1,22 @@ +/* + * (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu + * + * See file AUTHORS for a list of contributors. + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + #include <corsika/utl/CorsikaData.h> #include <cstdlib> #include <stdexcept> #include <string> -std::filesystem::path corsika::utl::CorsikaData(std::filesystem::path const& key) { +std::string corsika::utl::CorsikaData(std::string const& key) { if (auto const* p = std::getenv("CORSIKA_DATA"); p != nullptr) { - auto const path = std::filesystem::path(p) / key; + auto const path = std::string(p) + "/" + key; return path; } else { throw std::runtime_error("CORSIKA_DATA not set"); diff --git a/Framework/Utilities/CorsikaData.h b/Framework/Utilities/CorsikaData.h index 63e763aa6..7a381ca15 100644 --- a/Framework/Utilities/CorsikaData.h +++ b/Framework/Utilities/CorsikaData.h @@ -8,12 +8,12 @@ * the license. */ -#include <filesystem> +//#include <filesystem> #include <string> namespace corsika::utl { /** * returns the full path of the file \p filename within the CORSIKA_DATA directory */ - std::filesystem::path CorsikaData(std::filesystem::path const& filename); + std::string CorsikaData(std::string const& filename); } // namespace corsika::utl diff --git a/Processes/UrQMD/UrQMD.cc b/Processes/UrQMD/UrQMD.cc index ffa6593bb..09d171e26 100644 --- a/Processes/UrQMD/UrQMD.cc +++ b/Processes/UrQMD/UrQMD.cc @@ -31,7 +31,7 @@ using SetupStack = corsika::setup::Stack; using SetupParticle = corsika::setup::Stack::StackIterator; using SetupProjectile = corsika::setup::StackView::StackIterator; -UrQMD::UrQMD(std::filesystem::path const& xs_file) { +UrQMD::UrQMD(std::string const& xs_file) { readXSFile(xs_file); iniurqmd_(); } @@ -435,11 +435,11 @@ std::pair<int, int> corsika::process::UrQMD::ConvertToUrQMD( return mapPDGToUrQMD.at(static_cast<int>(GetPDG(code))); } -void UrQMD::readXSFile(std::filesystem::path const& filename) { +void UrQMD::readXSFile(std::string const& filename) { std::ifstream file(filename, std::ios::in); if (!file.is_open()) { - throw std::runtime_error(filename.native() + " could not be opened."); + throw std::runtime_error(filename + " could not be opened."); } std::string line; diff --git a/Processes/UrQMD/UrQMD.h b/Processes/UrQMD/UrQMD.h index 893fe3697..1ec6e289b 100644 --- a/Processes/UrQMD/UrQMD.h +++ b/Processes/UrQMD/UrQMD.h @@ -21,15 +21,14 @@ #include <boost/multi_array.hpp> #include <array> -#include <filesystem> #include <random> +#include <string> #include <utility> namespace corsika::process::UrQMD { class UrQMD : public corsika::process::InteractionProcess<UrQMD> { public: - UrQMD( - std::filesystem::path const& path = utl::CorsikaData("UrQMD/UrQMD-1.3.1-xs.dat")); + UrQMD(std::string const& path = utl::CorsikaData("UrQMD/UrQMD-1.3.1-xs.dat")); void Init() {} corsika::units::si::GrammageType GetInteractionLength( corsika::setup::Stack::StackIterator const&) const; @@ -51,7 +50,7 @@ namespace corsika::process::UrQMD { bool CanInteract(particles::Code) const; private: - void readXSFile(std::filesystem::path const&); + void readXSFile(std::string const&); corsika::random::RNG& fRNG = corsika::random::RNGManager::GetInstance().GetRandomStream("UrQMD"); -- GitLab