Elements  5.8
A C++ base framework for the Euclid Software.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Auxiliary.icpp
Go to the documentation of this file.
1 
21 #ifndef ELEMENTSKERNEL_ELEMENTSKERNEL__IMPL_AUXILIARY_ICPP_
22 #define ELEMENTSKERNEL_ELEMENTSKERNEL__IMPL_AUXILIARY_ICPP_
23 
24 #include <boost/filesystem.hpp> // for boost::filesystem
25 
26 #include "ElementsKernel/System.h" // for DEFAULT_INSTALL_PREFIX
27 #include "ElementsKernel/Exception.h" // for Exception
28 #include "ElementsKernel/Path.h" // for Path::VARIABLE, Path::Type
29  // for Path::getPathFromEnvVariable
30 namespace Elements {
31 
32 template <typename T>
33 boost::filesystem::path getAuxiliaryPath(const T& file_name, bool raise_exception) {
34 
35  auto location_list = getAuxiliaryLocations();
36 
37  auto result = Path::getPathFromLocations(file_name, location_list);
38 
39  if (result.empty() and raise_exception) {
40  throw Exception() << "The auxiliary path \"" << file_name << "\" cannot be found!";
41  }
42 
43  return result;
44 }
45 
46 } // namespace Elements
47 
48 #endif // ELEMENTSKERNEL_ELEMENTSKERNEL__IMPL_AUXILIARY_ICPP_
ELEMENTS_API std::vector< boost::filesystem::path > getAuxiliaryLocations(bool exist_only=false)
Definition: Auxiliary.cpp:50
This file is intended to iron out all the differences between systems (currently Linux and MacOSX) ...
boost::filesystem::path path
Definition: DataSyncUtils.h:33
boost::filesystem::path getPathFromLocations(const T &file_name, const std::vector< U > &locations)
retrieve path from a file name and a set of location to look into
Definition: Path.icpp:37
provide functions to retrieve resources pointed by environment variables
boost::filesystem::path getAuxiliaryPath(const T &file_name, bool raise_exception)
Definition: Auxiliary.icpp:33
defines the base Elements exception class