diff --git a/Framework/Utilities/CMakeLists.txt b/Framework/Utilities/CMakeLists.txt index 6baab4e54decf9812bc3c7cf0e0d438e89e72030..b5796bfd535759eae184faed36693902527255df 100644 --- a/Framework/Utilities/CMakeLists.txt +++ b/Framework/Utilities/CMakeLists.txt @@ -20,10 +20,12 @@ endif () set ( UTILITIES_SOURCES COMBoost.cc + CorsikaData.cc ${CORSIKA_FENV}) set ( UTILITIES_HEADERS + CorsikaData.h COMBoost.h Bit.h Singleton.h diff --git a/Framework/Utilities/CorsikaData.cc b/Framework/Utilities/CorsikaData.cc new file mode 100644 index 0000000000000000000000000000000000000000..1d30f5132ba670d2c5b22d5617b809f3f078e7fd --- /dev/null +++ b/Framework/Utilities/CorsikaData.cc @@ -0,0 +1,14 @@ +#include <corsika/utl/CorsikaData.h> + +#include <cstdlib> +#include <stdexcept> +#include <string> + +std::filesystem::path corsika::utl::CorsikaData(std::filesystem::path const& key) { + if (auto const* p = std::getenv("CORSIKA_DATA"); p != nullptr) { + auto const path = std::filesystem::path(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 new file mode 100644 index 0000000000000000000000000000000000000000..63e763aa6db1b6ba0e0cc19b4577616acdf8598a --- /dev/null +++ b/Framework/Utilities/CorsikaData.h @@ -0,0 +1,19 @@ +/* + * (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 <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); +} // namespace corsika::utl