File indexing completed on 2026-07-26 08:22:19
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "traccc/io/utils.hpp"
0010
0011
0012 #include <cstdlib>
0013 #include <filesystem>
0014 #include <iomanip>
0015 #include <sstream>
0016
0017 namespace traccc::io {
0018
0019 const std::string& data_directory() {
0020
0021 static const std::string data_dir = [] {
0022
0023 const char* env_dir = std::getenv("TRACCC_TEST_DATA_DIR");
0024 if (env_dir == nullptr) {
0025
0026
0027 return std::string(TRACCC_TEST_DATA_DIR) + "/";
0028 }
0029
0030 return std::string(env_dir) + "/";
0031 }();
0032
0033
0034 return data_dir;
0035 }
0036
0037 std::string get_event_filename(std::size_t event, std::string_view suffix) {
0038 std::ostringstream stream;
0039 stream << "event" << std::setfill('0') << std::setw(9) << event << suffix;
0040 return stream.str();
0041 }
0042
0043 std::string get_absolute_path(std::string_view path) {
0044
0045 if (std::filesystem::path(path).is_absolute()) {
0046 return std::string{path};
0047 }
0048
0049
0050 return std::filesystem::path(data_directory()) / std::filesystem::path(path);
0051 }
0052
0053 }