Gaudi Framework, version v21r11

Home   Generated: 30 Sep 2010

System::PathResolver Class Reference

#include <PathResolver.h>

List of all members.

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

Enumerator:
Ok 
EnvironmentVariableUndefined 
UnknownDirectory 

Definition at line 14 of file PathResolver.h.

Enumerator:
LocalSearch 
RecursiveSearch 

Definition at line 21 of file PathResolver.h.

00022     {
00023       LocalSearch,
00024       RecursiveSearch
00025     } SearchType;


Member Function Documentation

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.

00110                                       {
00111 
00112   const char* path_env = ::getenv (search_path.c_str ());
00113 
00114   std::string path_list;
00115 
00116   if (path_env != 0)
00117   {
00118     path_list = path_env;
00119   }
00120 
00121   return (find_file_from_list (logical_file_name, path_list, search_type));
00122 }

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

00130 {
00131   std::string result("");
00132 
00133   bf::path lfn( logical_file_name );
00134 
00135   /* bool found = */
00136   PR_find (lfn, search_list, PR_regular_file, search_type, result);
00137 
00138   // The following functionality was in the original PathResolver, but I believe
00139   // that it's WRONG. It extracts the filename of the requested item, and searches
00140   // for that if the preceding search fails. i.e., if you're looking for "B/a.txt",
00141   // and that fails, it will look for just "a.txt" in the search list.
00142 
00143   // if (! found && lfn.filename() != lfn ) {
00144   //   result = "";
00145   //   PR_find (lfn.filename(), search_list, PR_regular_file, search_type, result);
00146   // }
00147 
00148   return (result);
00149 }

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.

00156 {
00157   const char* path_env = ::getenv (search_path.c_str ());
00158 
00159   std::string path_list;
00160 
00161   if (path_env != 0)
00162     {
00163       path_list = path_env;
00164     }
00165 
00166   return (find_directory_from_list (logical_file_name, path_list, search_type));
00167 }

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

00175 {
00176   std::string result;
00177 
00178   if (!PR_find (logical_file_name, search_list, PR_directory, search_type, result))
00179   {
00180     result = "";
00181   }
00182 
00183   return (result);
00184 }

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

00191 {
00192   const char* path_env = ::getenv (search_path.c_str ());
00193 
00194   if (path_env == 0) return (EnvironmentVariableUndefined);
00195 
00196   std::string path_list (path_env);
00197 
00198   vector<string> spv;
00199   boost::split( spv, path_list, boost::is_any_of( path_separator ), boost::token_compress_on);
00200   vector<string>::iterator itr=spv.begin();
00201 
00202   try {
00203     for (; itr!= spv.end(); ++itr) {
00204       bf::path pp(*itr);
00205       if (!is_directory(pp)) {
00206         return (UnknownDirectory);
00207       }
00208     }
00209   } catch(bf::filesystem_error /*err*/) {
00210     return (UnknownDirectory);
00211   }
00212 
00213   return ( Ok );
00214 }


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

Generated at Thu Sep 30 09:59:09 2010 for Gaudi Framework, version v21r11 by Doxygen version 1.5.6 written by Dimitri van Heesch, © 1997-2004