| # Gaudi Framework, version v22r4 |

Home |  | Generated: Fri Sep 2 2011

Public Types | Static Public Member Functions

# 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

enum System::PathResolver::SearchPathStatus

Enumerator:

  Ok |
  EnvironmentVariableUndefined |
  UnknownDirectory |

Definition at line 14 of file PathResolver.h.

        {
          Ok,
          EnvironmentVariableUndefined,
          UnknownDirectory
        } SearchPathStatus;

enum System::PathResolver::SearchType

Enumerator:

  LocalSearch |
  RecursiveSearch |

Definition at line 21 of file PathResolver.h.

        {
          LocalSearch,
          RecursiveSearch
        } SearchType;

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

    {
      std::string path_list;
      if ( ! System::getEnv(search_path, path_list) )
        return (EnvironmentVariableUndefined);

      vector<string> spv;
      boost::split( spv, path_list, boost::is_any_of( path_separator ), boost::token_compress_on);
      vector<string>::iterator itr=spv.begin();

      try {
        for (; itr!= spv.end(); ++itr) {
          bf::path pp(*itr);
          if (!is_directory(pp)) {
            return (UnknownDirectory);
          }
        }
      } catch(bf::filesystem_error /*err*/) {
        return (UnknownDirectory);
      }

      return ( Ok );
    }

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

    {
      std::string path_list;
      System::getEnv(search_path, path_list);

      return (find_directory_from_list (logical_file_name, path_list, search_type));
    }

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

    {
      std::string result;

      if (!PR_find (logical_file_name, search_list, PR_directory, search_type, result))
      {
        result = "";
      }

      return (result);
    }

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

                                          {

      std::string path_list;
      System::getEnv(search_path, path_list);

      return (find_file_from_list (logical_file_name, path_list, search_type));
    }

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

    {
      std::string result("");

      bf::path lfn( logical_file_name );

      /* bool found = */
      PR_find (lfn, search_list, PR_regular_file, search_type, result);

      // The following functionality was in the original PathResolver, but I believe
      // that it's WRONG. It extracts the filename of the requested item, and searches
      // for that if the preceding search fails. i.e., if you're looking for "B/a.txt",
      // and that fails, it will look for just "a.txt" in the search list.

      // if (! found && lfn.filename() != lfn ) {
      //   result = "";
      //   PR_find (lfn.filename(), search_list, PR_regular_file, search_type, result);
      // }

      return (result);
    }

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v22r4/GaudiKernel/GaudiKernel/PathResolver.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v22r4/GaudiKernel/src/Lib/PathResolver.cpp

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines