Elements  5.12.0
A C++ base framework for the Euclid Software.
Auxiliary.cpp
Go to the documentation of this file.
1 
24 
25 #include <algorithm> // for remove_if
26 #include <iterator>
27 #include <map>
28 #include <string> // for string
29 #include <vector> // for vector
30 
31 #include <boost/filesystem/operations.hpp> // for exists
32 
33 #include "ElementsKernel/Path.h" // for Type, Item, VARIABLE
34 #include "ElementsKernel/System.h" // for DEFAULT_INSTALL_PREFIX
35 
36 using std::string;
37 
38 namespace Elements {
39 
42 }
43 
44 // instantiation of the most expected types
45 template Path::Item getAuxiliaryPath(const Path::Item& file_name, bool raise_exception);
46 template Path::Item getAuxiliaryPath(const string& file_name, bool raise_exception);
47 
49 
51 
52  auto location_list = Path::getLocations(Path::Type::auxiliary, exist_only);
53 
54  // extended to /usr/share/aux{dir,}
55  location_list.emplace_back(Path::Item(DEFAULT_INSTALL_PREFIX) / "share" / "auxdir");
56  // for backward compatibility with the former convention
57  location_list.emplace_back(Path::Item(DEFAULT_INSTALL_PREFIX) / "share" / "aux");
58 
59  if (exist_only) {
60  auto new_end = std::remove_if(location_list.begin(),
61  location_list.end(),
62  [](const Path::Item& p){
63  return (not boost::filesystem::exists(p));
64  });
65  location_list.erase(new_end, location_list.end());
66  }
67 
68  return location_list;
69 }
70 
71 } // namespace Elements
provide functions to retrieve auxiliary files
provide functions to retrieve resources pointed by environment variables
This file is intended to iron out all the differences between systems (currently Linux and MacOSX)
ELEMENTS_API const std::map< Type, const std::string > VARIABLE
map containing the name of the path variable for each type
Definition: Path.cpp:44
ELEMENTS_API std::vector< Item > getLocations(const Type &path_type, bool exist_only=false)
function to get the locations for the specific type
Definition: Path.cpp:96
boost::filesystem::path Item
Definition: Path.h:61
const std::string DEFAULT_INSTALL_PREFIX
constant for the canonical installation prefix (on Linux and MacOSX at least)
Definition: System.h:90
ELEMENTS_API std::vector< Path::Item > getAuxiliaryLocations(bool exist_only=false)
Definition: Auxiliary.cpp:48
ELEMENTS_API Path::Item getAuxiliaryPath(const T &file_name, bool raise_exception=true)
ELEMENTS_API std::string getAuxiliaryVariableName()
Definition: Auxiliary.cpp:40
T remove_if(T... args)