The Gaudi Framework  v29r0 (ff2e7097)
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 10 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 178 of file PathResolver.cpp.

179  {
180  std::string path_list;
181  if ( !System::getEnv( search_path, path_list ) ) return ( EnvironmentVariableUndefined );
182 
183  vector<string> spv;
184  boost::split( spv, path_list, boost::is_any_of( path_separator ), boost::token_compress_on );
185 
186  try {
187  for ( const auto& itr : spv ) {
188  bf::path pp( itr );
189  if ( !is_directory( pp ) ) {
190  return ( UnknownDirectory );
191  }
192  }
193  } catch ( bf::filesystem_error /*err*/ ) {
194  return ( UnknownDirectory );
195  }
196 
197  return ( Ok );
198  }
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
Definition: System.cpp:581
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 153 of file PathResolver.cpp.

155  {
156  std::string path_list;
157  System::getEnv( search_path, path_list );
158 
159  return ( find_directory_from_list( logical_file_name, path_list, search_type ) );
160  }
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
Definition: System.cpp:581
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 164 of file PathResolver.cpp.

166  {
167  std::string result;
168 
169  if ( !PR_find( logical_file_name, search_list, PR_directory, search_type, result ) ) {
170  result = "";
171  }
172 
173  return ( result );
174  }
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 116 of file PathResolver.cpp.

118  {
119 
120  std::string path_list;
121  System::getEnv( search_path, path_list );
122 
123  return ( find_file_from_list( logical_file_name, path_list, search_type ) );
124  }
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
Definition: System.cpp:581
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 128 of file PathResolver.cpp.

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

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