30#include "G4FindDataDir.hh"
38#define setenv(name, value, overwrite) _putenv_s(name, value)
43static const char *
const system_paths[] = {
44 GEANT4_INSTALL_FULL_DATADIR,
52 "/cvmfs/geant4.cern.ch"
56static const char *
const data_paths[] = {
58 GEANT4_INSTALL_DATADIR,
59 CMAKE_INSTALL_DATADIR,
66static const char* G4GetDataDir(
const char* name)
68 for (
const auto& d : dataset_definitions)
69 if (strcmp(name, d.env) == 0)
80 for (
const auto data_path : data_paths) {
82 if (strcmp(data_path,
".") == 0)
85 datadir /= path(data_path) / dataset;
86 if (is_directory(absolute(datadir)))
87 return setenv(name, absolute(datadir).
string().c_str(), 0) == 0 ? std::getenv(name) : nullptr;
95#if defined(G4MULTITHREADED)
96 static std::mutex
mutex;
97 std::lock_guard<std::mutex> lock(
mutex);
101 if (
const char *datadir = std::getenv(name))
105 if (
const char *dataset = G4GetDataDir(name)) {
107 if (
const char *basedir = std::getenv(
"GEANT4_DATA_DIR"))
111 for (
const auto prefix : system_paths)
125#if defined(G4MULTITHREADED)
126 static std::mutex
mutex;
127 std::lock_guard<std::mutex> lock(
mutex);
130 if (
const char *datadir = std::getenv(name))
const char * G4FindDataDir(const char *)