System::PathResolver Class Reference

#include </scratch/z5/marcocle/GaudiDocs/lhcb-release/825/GAUDI/GAUDI_v26r3/InstallArea/x86_64-slc6-gcc48-opt/include/GaudiKernel/PathResolver.h>

Public Types

enum  SearchPathStatus {
  Ok, EnvironmentVariableUndefined, UnknownDirectory, Ok,
  EnvironmentVariableUndefined, UnknownDirectory
}
 
enum  SearchType { LocalSearch, RecursiveSearch, LocalSearch, RecursiveSearch }
 
enum  SearchPathStatus {
  Ok, EnvironmentVariableUndefined, UnknownDirectory, Ok,
  EnvironmentVariableUndefined, UnknownDirectory
}
 
enum  SearchType { LocalSearch, RecursiveSearch, 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)
 
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 10 of file PathResolver.h.

Member Enumeration Documentation

Enumerator
Ok 
EnvironmentVariableUndefined 
UnknownDirectory 
Ok 
EnvironmentVariableUndefined 
UnknownDirectory 

Definition at line 14 of file PathResolver.h.

Enumerator
Ok 
EnvironmentVariableUndefined 
UnknownDirectory 
Ok 
EnvironmentVariableUndefined 
UnknownDirectory 

Definition at line 14 of file PathResolver.h.

Enumerator
LocalSearch 
RecursiveSearch 
LocalSearch 
RecursiveSearch 

Definition at line 21 of file PathResolver.h.

Enumerator
LocalSearch 
RecursiveSearch 
LocalSearch 
RecursiveSearch 

Definition at line 21 of file PathResolver.h.

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 197 of file PathResolver.cpp.

198 {
199  std::string path_list;
200  if ( ! System::getEnv(search_path, path_list) )
202 
203  vector<string> spv;
204  boost::split( spv, path_list, boost::is_any_of( path_separator ), boost::token_compress_on);
205  vector<string>::iterator itr=spv.begin();
206 
207  try {
208  for (; itr!= spv.end(); ++itr) {
209  bf::path pp(*itr);
210  if (!is_directory(pp)) {
211  return (UnknownDirectory);
212  }
213  }
214  } catch(bf::filesystem_error /*err*/) {
215  return (UnknownDirectory);
216  }
217 
218  return ( Ok );
219 }
list path
Definition: __init__.py:15
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
Definition: System.cpp:618
static 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
static std::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
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 166 of file PathResolver.cpp.

169 {
170  std::string path_list;
171  System::getEnv(search_path, path_list);
172 
173  return (find_directory_from_list (logical_file_name, path_list, search_type));
174 }
static std::string find_directory_from_list(const std::string &logical_file_name, const std::string &search_list, SearchType search_type=LocalSearch)
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
Definition: System.cpp:618
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 179 of file PathResolver.cpp.

182 {
183  std::string result;
184 
185  if (!PR_find (logical_file_name, search_list, PR_directory, search_type, result))
186  {
187  result = "";
188  }
189 
190  return (result);
191 }
static std::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
static std::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
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 127 of file PathResolver.cpp.

129  {
130 
131  std::string path_list;
132  System::getEnv(search_path, path_list);
133 
134  return (find_file_from_list (logical_file_name, path_list, search_type));
135 }
static std::string find_file_from_list(const std::string &logical_file_name, const std::string &search_list, SearchType search_type=LocalSearch)
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
Definition: System.cpp:618
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 140 of file PathResolver.cpp.

143 {
144  std::string result("");
145 
146  bf::path lfn( logical_file_name );
147 
148  /* bool found = */
149  PR_find (lfn, search_list, PR_regular_file, search_type, result);
150 
151  // The following functionality was in the original PathResolver, but I believe
152  // that it's WRONG. It extracts the filename of the requested item, and searches
153  // for that if the preceding search fails. i.e., if you're looking for "B/a.txt",
154  // and that fails, it will look for just "a.txt" in the search list.
155 
156  // if (! found && lfn.filename() != lfn ) {
157  // result = "";
158  // PR_find (lfn.filename(), search_list, PR_regular_file, search_type, result);
159  // }
160 
161  return (result);
162 }
list path
Definition: __init__.py:15
static 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

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