| The Gaudi Framework v32r1 (f65d50dc)

Public Types | Static Public Member Functions | List of all members
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

## ◆ SearchPathStatus

enum System::PathResolver::SearchPathStatus

Enumerator
Ok |
EnvironmentVariableUndefined |
UnknownDirectory |

Definition at line 13 of file PathResolver.h.

13 { Ok, EnvironmentVariableUndefined, UnknownDirectory } SearchPathStatus;
System::PathResolver::Ok
Definition: PathResolver.h:13
System::PathResolver::SearchPathStatus
SearchPathStatus
Definition: PathResolver.h:13
System::PathResolver::EnvironmentVariableUndefined
Definition: PathResolver.h:13
System::PathResolver::UnknownDirectory
Definition: PathResolver.h:13

## ◆ SearchType

enum System::PathResolver::SearchType

Enumerator
LocalSearch |
RecursiveSearch |

Definition at line 15 of file PathResolver.h.

15 { LocalSearch, RecursiveSearch } SearchType;
System::PathResolver::LocalSearch
Definition: PathResolver.h:15
System::PathResolver::RecursiveSearch
Definition: PathResolver.h:15
System::PathResolver::SearchType
SearchType
Definition: PathResolver.h:15

## 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 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 }
System::getEnv
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
Definition: System.cpp:369
System::PathResolver::Ok
Definition: PathResolver.h:13
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:932
std::string
STL class.
System::PathResolver::EnvironmentVariableUndefined
Definition: PathResolver.h:13
std::vector
STL class.
compareOutputFiles.pp
pp
Definition: compareOutputFiles.py:495
System::PathResolver::UnknownDirectory
Definition: PathResolver.h:13

## ◆ 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 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 }
System::getEnv
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
Definition: System.cpp:369
std::string
STL class.
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:153

## ◆ 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 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 }
System::PR_directory
Definition: PathResolver.cpp:35
std::string
STL class.

## ◆ 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 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 }
System::getEnv
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
Definition: System.cpp:369
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:119
std::string
STL class.

## ◆ 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 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 }
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:932
std::string
STL class.
System::PR_regular_file
Definition: PathResolver.cpp:35

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

- GaudiKernel/GaudiKernel/PathResolver.h
- GaudiKernel/src/Lib/PathResolver.cpp