| # Gaudi Framework, version v20r4
Generated: 8 Jan 2009

# System::PathResolver Class Reference

`#include <PathResolver.h>`

List of all members.

## Detailed Description

Definition at line 8 of file 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)

## Member Enumeration Documentation

enum System::PathResolver::SearchPathStatus

Enumerator:

  Ok |
  EnvironmentVariableUndefined |
  UnknownDirectory |

Definition at line 11 of file PathResolver.h.

    00012     {
    00013       Ok,
    00014       EnvironmentVariableUndefined,
    00015       UnknownDirectory
    00016     } SearchPathStatus;

enum System::PathResolver::SearchType

Enumerator:

  LocalSearch |
  RecursiveSearch |

Definition at line 18 of file PathResolver.h.

    00019     {
    00020       LocalSearch,
    00021       RecursiveSearch
    00022     } SearchType;

## Member Function Documentation

std::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 490 of file PathResolver.cpp.

    00493 {
    00494   const char* path_env = ::getenv (search_path.c_str ());
    00495
    00496   std::string path_list;
    00497
    00498   if (path_env != 0)
    00499     {
    00500       path_list = path_env;
    00501     }
    00502
    00503   return (find_file_from_list (logical_file_name, path_list, search_type));
    00504 }

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

    00509 {
    00510   std::string result;
    00511
    00512   if (!PR_find_from_list (logical_file_name, search_list, PR_regular_file, search_type, result))
    00513     {
    00514       result = "";
    00515     }
    00516
    00517   return (result);
    00518 }

std::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 520 of file PathResolver.cpp.

    00523 {
    00524   const char* path_env = ::getenv (search_path.c_str ());
    00525
    00526   std::string path_list;
    00527
    00528   if (path_env != 0)
    00529     {
    00530       path_list = path_env;
    00531     }
    00532
    00533   return (find_directory_from_list (logical_file_name, path_list, search_type));
    00534 }

std::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 536 of file PathResolver.cpp.

    00539 {
    00540   std::string result;
    00541
    00542   if (!PR_find_from_list (logical_file_name, search_list, PR_directory, search_type, result))
    00543     {
    00544       result = "";
    00545     }
    00546
    00547   return (result);
    00548 }

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

    00551 {
    00552   const char* path_env = ::getenv (search_path.c_str ());
    00553
    00554   if (path_env == 0) return (EnvironmentVariableUndefined);
    00555
    00556 #ifdef _WIN32
    00557   static const char path_separator = ';';
    00558 #else
    00559   static const char path_separator = ':';
    00560 #endif
    00561
    00562   std::string path_list (path_env);
    00563
    00564   std::string::size_type pos = 0;
    00565
    00566   for (int i = 0;;i++)
    00567     {
    00568       bool ending = false;
    00569
    00570       std::string::size_type next = path_list.find (path_separator, pos);
    00571
    00572       std::string path = path_list.substr (pos, next - pos);
    00573
    00574       if (next == std::string::npos)
    00575         {
    00576           path = path_list.substr (pos);
    00577           ending = true;
    00578         }
    00579       else
    00580         {
    00581           path = path_list.substr (pos, next - pos);
    00582           pos = next + 1;
    00583         }
    00584
    00585       std::string real_name = "";
    00586
    00587       if (!PR_test_exist (path, real_name, PR_directory))
    00588         {
    00589           return (UnknownDirectory);
    00590         }
    00591
    00592       if (ending) break;
    00593     }
    00594
    00595   return (Ok);
    00596 }

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

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