| # Gaudi Framework, version v21r8 |

Home |  | Generated: 17 Mar 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 9 of file PathResolver.h.

## Member Enumeration Documentation

enum System::PathResolver::SearchPathStatus

Enumerator:

  Ok |
  EnvironmentVariableUndefined |
  UnknownDirectory |

Definition at line 12 of file PathResolver.h.

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

enum System::PathResolver::SearchType

Enumerator:

  LocalSearch |
  RecursiveSearch |

Definition at line 19 of file PathResolver.h.

    00020     {
    00021       LocalSearch,
    00022       RecursiveSearch
    00023     } 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 488 of file PathResolver.cpp.

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

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

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

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

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

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

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

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

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

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

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