Elements  5.8
A C++ base framework for the Euclid Software.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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>
32 #include <boost/filesystem/path.hpp>
33 
34 #include "ElementsKernel/Path.h" // for Type and VARIABLE
35 #include "ElementsKernel/System.h" // for DEFAULT_INSTALL_PREFIX
36 
37 using std::string;
39 
40 namespace Elements {
41 
44 }
45 
46 // instantiation of the most expected types
47 template path getAuxiliaryPath(const path& file_name, bool raise_exception);
48 template path getAuxiliaryPath(const string& file_name, bool raise_exception);
49 
51 
53 
54  auto location_list = Path::getLocationsFromEnv(Path::VARIABLE.at(Path::Type::auxiliary), exist_only);
55 
56  // extended to /usr/share/aux{dir,}
57  location_list.push_back(path(DEFAULT_INSTALL_PREFIX) / "share" / "auxdir");
58  // for backward compatibility with the former convention
59  location_list.push_back(path(DEFAULT_INSTALL_PREFIX) / "share" / "aux");
60 
61  if (exist_only) {
62  auto new_end = std::remove_if(location_list.begin(),
63  location_list.end(),
64  [](path p){
65  return boost::filesystem::exists(p);
66  });
67  location_list.erase(new_end, location_list.end());
68  }
69 
70  return location_list;
71 }
72 
73 } // namespace Elements
ELEMENTS_API std::vector< boost::filesystem::path > getAuxiliaryLocations(bool exist_only=false)
Definition: Auxiliary.cpp:50
provide functions to retrieve auxiliary files
ELEMENTS_API std::vector< boost::filesystem::path > getLocationsFromEnv(const std::string &path_variable, bool exist_only=false)
function to get the locations from an environment variable
Definition: Path.cpp:79
T remove_if(T...args)
ELEMENTS_API std::string getAuxiliaryVariableName()
Definition: Auxiliary.cpp:42
STL class.
This file is intended to iron out all the differences between systems (currently Linux and MacOSX) ...
boost::filesystem::path path
Definition: DataSyncUtils.h:33
ELEMENTS_API const std::map< Type, const std::string > VARIABLE
map containing the name of the path variable for each type
Definition: Path.cpp:46
STL class.
provide functions to retrieve resources pointed by environment variables
const std::string DEFAULT_INSTALL_PREFIX
constant for the canonical installation prefix (on Linux and MacOSX at least)
Definition: System.h:90
boost::filesystem::path getAuxiliaryPath(const T &file_name, bool raise_exception)
Definition: Auxiliary.icpp:33