|
Gaudi Framework, version v22r0 |
| Home | Generated: 9 Feb 2011 |
#include <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) |
Definition at line 10 of file PathResolver.h.
Definition at line 14 of file PathResolver.h.
00015 { 00016 Ok, 00017 EnvironmentVariableUndefined, 00018 UnknownDirectory 00019 } SearchPathStatus;
Definition at line 21 of file PathResolver.h.
00022 { 00023 LocalSearch, 00024 RecursiveSearch 00025 } SearchType;
| PathResolver::SearchPathStatus System::PathResolver::check_search_path | ( | const std::string & | search_path | ) | [static] |
search_path the name of a path-like environment variableOk, EnvironmentVariableUndefined, UnknownDirectory Definition at line 201 of file PathResolver.cpp.
00202 { 00203 const char* path_env = ::getenv (search_path.c_str ()); 00204 00205 if (path_env == 0) return (EnvironmentVariableUndefined); 00206 00207 std::string path_list (path_env); 00208 00209 vector<string> spv; 00210 boost::split( spv, path_list, boost::is_any_of( path_separator ), boost::token_compress_on); 00211 vector<string>::iterator itr=spv.begin(); 00212 00213 try { 00214 for (; itr!= spv.end(); ++itr) { 00215 bf::path pp(*itr); 00216 if (!is_directory(pp)) { 00217 return (UnknownDirectory); 00218 } 00219 } 00220 } catch(bf::filesystem_error /*err*/) { 00221 return (UnknownDirectory); 00222 } 00223 00224 return ( Ok ); 00225 }
| 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 RecursiveSearchDefinition at line 164 of file PathResolver.cpp.
00167 { 00168 const char* path_env = ::getenv (search_path.c_str ()); 00169 00170 std::string path_list; 00171 00172 if (path_env != 0) 00173 { 00174 path_list = path_env; 00175 } 00176 00177 return (find_directory_from_list (logical_file_name, path_list, search_type)); 00178 }
| 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 RecursiveSearchDefinition at line 183 of file PathResolver.cpp.
00186 { 00187 std::string result; 00188 00189 if (!PR_find (logical_file_name, search_list, PR_directory, search_type, result)) 00190 { 00191 result = ""; 00192 } 00193 00194 return (result); 00195 }
| 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 Definition at line 119 of file PathResolver.cpp.
00121 { 00122 00123 const char* path_env = ::getenv (search_path.c_str ()); 00124 00125 std::string path_list; 00126 00127 if (path_env != 0) 00128 { 00129 path_list = path_env; 00130 } 00131 00132 return (find_file_from_list (logical_file_name, path_list, search_type)); 00133 }
| 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 Definition at line 138 of file PathResolver.cpp.
00141 { 00142 std::string result(""); 00143 00144 bf::path lfn( logical_file_name ); 00145 00146 /* bool found = */ 00147 PR_find (lfn, search_list, PR_regular_file, search_type, result); 00148 00149 // The following functionality was in the original PathResolver, but I believe 00150 // that it's WRONG. It extracts the filename of the requested item, and searches 00151 // for that if the preceding search fails. i.e., if you're looking for "B/a.txt", 00152 // and that fails, it will look for just "a.txt" in the search list. 00153 00154 // if (! found && lfn.filename() != lfn ) { 00155 // result = ""; 00156 // PR_find (lfn.filename(), search_list, PR_regular_file, search_type, result); 00157 // } 00158 00159 return (result); 00160 }