| # Gaudi Framework, version v20r2
Generated: 18 Jul 2008

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

- Search for |

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# 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)
| `logical_file_name` the name of the file to locate in the search path
static std::string | find_file_from_list (const std::string &logical_file_name, const std::string &search_list, SearchType search_type=LocalSearch)
| `logical_file_name` the name of the file to locate in the search path
static std::string | find_directory (const std::string &logical_file_name, const std::string &search_path, SearchType search_type=LocalSearch)
| `logical_file_name` the name of the directory to locate in the search path
static std::string | find_directory_from_list (const std::string &logical_file_name, const std::string &search_list, SearchType search_type=LocalSearch)
| `logical_file_name` the name of the directory to locate in the search path
static SearchPathStatus | check_search_path (const std::string &search_path)
| `search_path` the name of a path-like environment variable

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

References std::basic_string< _CharT, _Traits, _Alloc >::c_str(), and find_file_from_list().

Referenced by PartPropSvc::initialize(), System::PathResolverFindDataFile(), System::PathResolverFindFile(), and System::PathResolverFindXMLFile().

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

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

References System::PR_find_from_list(), and System::PR_regular_file.

Referenced by find_file(), and System::PathResolverFindFileFromList().

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

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

References std::basic_string< _CharT, _Traits, _Alloc >::c_str(), and find_directory_from_list().

Referenced by System::PathResolverFindDirectory().

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

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

References System::PR_directory, and System::PR_find_from_list().

Referenced by find_directory(), and System::PathResolverFindDirectoryFromList().

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

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

References std::basic_string< _CharT, _Traits, _Alloc >::c_str(), EnvironmentVariableUndefined, std::basic_string< _CharT, _Traits, _Alloc >::find(), std::basic_string< _CharT, _Traits, _Alloc >::npos, Ok, Gaudi::Utils::Histos::path(), System::PR_directory, System::PR_test_exist(), std::basic_string< _CharT, _Traits, _Alloc >::substr(), and UnknownDirectory.

Referenced by System::PathResolverCheckSearchPath().

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

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

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