The Gaudi Framework  v31r0 (aeb156f0)
System::PathResolver Class Reference

#include <GaudiKernel/PathResolver.h>

Public Types

enum  SearchPathStatus { Ok, EnvironmentVariableUndefined, UnknownDirectory }
 
enum  SearchType { LocalSearch, RecursiveSearch }
 

Static Public Member Functions

static std::string find_file (const std::string &logical_file_name, const std::string &search_path, SearchType search_type=LocalSearch)
 
static std::string find_file_from_list (const std::string &logical_file_name, const std::string &search_list, SearchType search_type=LocalSearch)
 
static std::string find_directory (const std::string &logical_file_name, const std::string &search_path, SearchType search_type=LocalSearch)
 
static std::string find_directory_from_list (const std::string &logical_file_name, const std::string &search_list, SearchType search_type=LocalSearch)
 
static SearchPathStatus check_search_path (const std::string &search_path)
 

Detailed Description

Definition at line 9 of file PathResolver.h.

Member Enumeration Documentation

Member Function Documentation

PathResolver::SearchPathStatus System::PathResolver::check_search_path ( const std::string search_path)
static
  • search_path the name of a path-like environment variable
Returns
the result of the verification. Can be one of Ok, EnvironmentVariableUndefined, UnknownDirectory

Definition at line 164 of file PathResolver.cpp.

164  {
165  std::string path_list;
166  if ( !System::getEnv( search_path, path_list ) ) return ( EnvironmentVariableUndefined );
167 
168  vector<string> spv;
169  boost::split( spv, path_list, boost::is_any_of( path_separator ), boost::token_compress_on );
170 
171  try {
172  for ( const auto& itr : spv ) {
173  bf::path pp( itr );
174  if ( !is_directory( pp ) ) { return ( UnknownDirectory ); }
175  }
176  } catch ( const bf::filesystem_error& /*err*/ ) { return ( UnknownDirectory ); }
177 
178  return ( Ok );
179  }
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
Definition: System.cpp:380
STL class.
STL class.
string System::PathResolver::find_directory ( const std::string logical_file_name,
const std::string search_path,
SearchType  search_type = LocalSearch 
)
static
  • logical_file_name the name of the directory to locate in the search path
  • search_path the name of a path-like environment variable
  • search_type characterizes the type of search. Can be either LocalSearch or RecursiveSearch
Returns
the physical name of the located directory or empty string if not found

Definition at line 143 of file PathResolver.cpp.

144  {
145  std::string path_list;
146  System::getEnv( search_path, path_list );
147 
148  return ( find_directory_from_list( logical_file_name, path_list, search_type ) );
149  }
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
Definition: System.cpp:380
STL class.
static std::string find_directory_from_list(const std::string &logical_file_name, const std::string &search_list, SearchType search_type=LocalSearch)
string System::PathResolver::find_directory_from_list ( const std::string logical_file_name,
const std::string search_list,
SearchType  search_type = LocalSearch 
)
static
  • logical_file_name the name of the directory to locate in the search path
  • search_list the prioritized list of possible locations separated by the usual path separator
  • search_type characterizes the type of search. Can be either LocalSearch or RecursiveSearch
Returns
the physical name of the located directory or empty string if not found

Definition at line 153 of file PathResolver.cpp.

154  {
155  std::string result;
156 
157  if ( !PR_find( logical_file_name, search_list, PR_directory, search_type, result ) ) { result = ""; }
158 
159  return ( result );
160  }
STL class.
string System::PathResolver::find_file ( const std::string logical_file_name,
const std::string search_path,
SearchType  search_type = LocalSearch 
)
static
  • logical_file_name the name of the file to locate in the search path
  • search_path the name of a path-like environment variable
  • search_type characterizes the type of search. Can be either LocalSearch or RecursiveSearch
Returns
the physical name of the located file or empty string if not found

Definition at line 108 of file PathResolver.cpp.

109  {
110 
111  std::string path_list;
112  System::getEnv( search_path, path_list );
113 
114  return ( find_file_from_list( logical_file_name, path_list, search_type ) );
115  }
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
Definition: System.cpp:380
static std::string find_file_from_list(const std::string &logical_file_name, const std::string &search_list, SearchType search_type=LocalSearch)
STL class.
std::string System::PathResolver::find_file_from_list ( const std::string logical_file_name,
const std::string search_list,
SearchType  search_type = LocalSearch 
)
static
  • logical_file_name the name of the file to locate in the search path
  • search_list the prioritized list of possible locations separated by the usual path separator
  • search_type characterizes the type of search. Can be either LocalSearch or RecursiveSearch
Returns
the physical name of the located file or empty string if not found

Definition at line 119 of file PathResolver.cpp.

120  {
121  std::string result( "" );
122 
123  bf::path lfn( logical_file_name );
124 
125  /* bool found = */
126  PR_find( lfn, search_list, PR_regular_file, search_type, result );
127 
128  // The following functionality was in the original PathResolver, but I believe
129  // that it's WRONG. It extracts the filename of the requested item, and searches
130  // for that if the preceding search fails. i.e., if you're looking for "B/a.txt",
131  // and that fails, it will look for just "a.txt" in the search list.
132 
133  // if (! found && lfn.filename() != lfn ) {
134  // result = "";
135  // PR_find (lfn.filename(), search_list, PR_regular_file, search_type, result);
136  // }
137 
138  return ( result );
139  }
STL class.

The documentation for this class was generated from the following files: