The Gaudi Framework  v40r0 (475e45c1)
System::PathResolver Class Reference

#include </builds/gaudi/Gaudi/GaudiKernel/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 18 of file PathResolver.h.

Member Enumeration Documentation

◆ SearchPathStatus

Enumerator
Ok 
EnvironmentVariableUndefined 
UnknownDirectory 

Definition at line 22 of file PathResolver.h.

◆ SearchType

Enumerator
LocalSearch 
RecursiveSearch 

Definition at line 24 of file PathResolver.h.

Member Function Documentation

◆ check_search_path()

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

148  {
149  std::string path_list;
150  if ( !System::getEnv( search_path, path_list ) ) return ( EnvironmentVariableUndefined );
151 
152  vector<string> spv;
153  boost::split( spv, path_list, boost::is_any_of( path_separator ), boost::token_compress_on );
154 
155  try {
156  for ( const auto& itr : spv ) {
157  bf::path pp( itr );
158  if ( !is_directory( pp ) ) { return ( UnknownDirectory ); }
159  }
160  } catch ( const bf::filesystem_error& /*err*/ ) { return ( UnknownDirectory ); }
161 
162  return ( Ok );
163  }

◆ find_directory()

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

132  {
133  std::string path_list;
134  System::getEnv( search_path, path_list );
135 
136  return ( find_directory_from_list( logical_file_name, path_list, search_type ) );
137  }

◆ find_directory_from_list()

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

140  {
141  std::string result;
142 
143  if ( !PR_find( logical_file_name, search_list, PR_directory, search_type, result ) ) { result = ""; }
144 
145  return ( result );
146  }

◆ find_file()

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

101  {
102 
103  std::string path_list;
104  System::getEnv( search_path, path_list );
105 
106  return ( find_file_from_list( logical_file_name, path_list, search_type ) );
107  }

◆ find_file_from_list()

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

110  {
111  std::string result( "" );
112 
113  bf::path lfn( logical_file_name );
114 
115  /* bool found = */
116  PR_find( lfn, search_list, PR_regular_file, search_type, result );
117 
118  // The following functionality was in the original PathResolver, but I believe
119  // that it's WRONG. It extracts the filename of the requested item, and searches
120  // for that if the preceding search fails. i.e., if you're looking for "B/a.txt",
121  // and that fails, it will look for just "a.txt" in the search list.
122 
123  // if (! found && lfn.filename() != lfn ) {
124  // result = "";
125  // PR_find (lfn.filename(), search_list, PR_regular_file, search_type, result);
126  // }
127 
128  return ( result );
129  }

The documentation for this class was generated from the following files:
AtlasMCRecoFullPrecedenceDump.path
path
Definition: AtlasMCRecoFullPrecedenceDump.py:49
System::getEnv
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
Definition: System.cpp:376
System::PathResolver::RecursiveSearch
@ RecursiveSearch
Definition: PathResolver.h:24
System::PathResolver::EnvironmentVariableUndefined
@ EnvironmentVariableUndefined
Definition: PathResolver.h:22
System::PathResolver::UnknownDirectory
@ UnknownDirectory
Definition: PathResolver.h:22
System::PathResolver::Ok
@ Ok
Definition: PathResolver.h:22
System::PR_regular_file
@ PR_regular_file
Definition: PathResolver.cpp:31
System::PR_directory
@ PR_directory
Definition: PathResolver.cpp:31
System::PathResolver::find_directory_from_list
static std::string find_directory_from_list(const std::string &logical_file_name, const std::string &search_list, SearchType search_type=LocalSearch)
Definition: PathResolver.cpp:139
System::PathResolver::LocalSearch
@ LocalSearch
Definition: PathResolver.h:24
compareOutputFiles.pp
pp
Definition: compareOutputFiles.py:507
System::PathResolver::SearchType
SearchType
Definition: PathResolver.h:24
System::PathResolver::SearchPathStatus
SearchPathStatus
Definition: PathResolver.h:22
System::PathResolver::find_file_from_list
static std::string find_file_from_list(const std::string &logical_file_name, const std::string &search_list, SearchType search_type=LocalSearch)
Definition: PathResolver.cpp:109