PathResolver Class Reference

#include <PathResolver.h>

List of all members.

Public Types

 Ok
 EnvironmentVariableUndefined
 UnknownDirectory
 LocalSearch
 RecursiveSearch
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 6 of file PathResolver.h.


Member Enumeration Documentation

enum PathResolver::SearchPathStatus

Enumerator:
Ok 
EnvironmentVariableUndefined 
UnknownDirectory 

Definition at line 9 of file PathResolver.h.

enum PathResolver::SearchType

Enumerator:
LocalSearch 
RecursiveSearch 

Definition at line 16 of file PathResolver.h.

00017     {
00018       LocalSearch,
00019       RecursiveSearch
00020     } SearchType;


Member Function Documentation

PathResolver::SearchPathStatus PathResolver::check_search_path ( const std::string search_path  )  [static]

Returns:
the result of the verification. Can be one of Ok, EnvironmentVariableUndefined, UnknownDirectory

Definition at line 600 of file PathResolver.cxx.

References EnvironmentVariableUndefined, genRecEmupikp::i, next, RealDBUtil::npos, Ok, boss::pos, PR_directory, PR_test_exist(), deljobs::string, and UnknownDirectory.

Referenced by PathResolverCheckSearchPath().

00601 {
00602   const char* path_env = ::getenv (search_path.c_str ());
00603 
00604   if (path_env == 0) return (EnvironmentVariableUndefined);
00605 
00606 #ifdef WIN32
00607   static const char path_separator = ';';
00608 #else
00609   static const char path_separator = ':';
00610 #endif
00611 
00612   std::string path_list (path_env);
00613 
00614   std::string::size_type pos = 0;
00615 
00616   for (int i = 0;;i++)
00617     {
00618       bool ending = false;
00619 
00620       std::string::size_type next = path_list.find (path_separator, pos);
00621 
00622       std::string path = path_list.substr (pos, next - pos);
00623 
00624       if (next == std::string::npos)
00625         {
00626           path = path_list.substr (pos);
00627           ending = true;
00628         }
00629       else
00630         {
00631           path = path_list.substr (pos, next - pos);
00632           pos = next + 1;
00633         }
00634 
00635       std::string real_name = "";
00636 
00637       if (!PR_test_exist (path, real_name, PR_directory))
00638         {
00639           return (UnknownDirectory);
00640         }
00641 
00642       if (ending) break;
00643     }
00644 
00645   return (Ok);
00646 }

std::string PathResolver::find_directory ( const std::string logical_file_name,
const std::string search_path,
SearchType  search_type = LocalSearch 
) [static]

Returns:
the physical name of the located directory or empty string if not found

Definition at line 570 of file PathResolver.cxx.

References find_directory_from_list(), and deljobs::string.

Referenced by PathResolverFindDirectory().

00573 {
00574   const char* path_env = ::getenv (search_path.c_str ());
00575 
00576   std::string path_list;
00577 
00578   if (path_env != 0)
00579     {
00580       path_list = path_env;
00581     }
00582 
00583   return (find_directory_from_list (logical_file_name, path_list, search_type));
00584 }

std::string PathResolver::find_directory_from_list ( const std::string logical_file_name,
const std::string search_list,
SearchType  search_type = LocalSearch 
) [static]

Returns:
the physical name of the located directory or empty string if not found

Definition at line 586 of file PathResolver.cxx.

References PR_directory, PR_find_from_list(), and deljobs::string.

Referenced by find_directory(), and PathResolverFindDirectoryFromList().

00589 {
00590   std::string result;
00591 
00592   if (!PR_find_from_list (logical_file_name, search_list, PR_directory, search_type, result))
00593     {
00594       result = "";
00595     }
00596 
00597   return (result);
00598 }

std::string PathResolver::find_file ( const std::string logical_file_name,
const std::string search_path,
SearchType  search_type = LocalSearch 
) [static]

Returns:
the physical name of the located file or empty string if not found

Definition at line 540 of file PathResolver.cxx.

References find_file_from_list(), and deljobs::string.

Referenced by main(), PathResolverFindDataFile(), PathResolverFindFile(), and PathResolverFindXMLFile().

00543 {
00544   const char* path_env = ::getenv (search_path.c_str ());
00545 
00546   std::string path_list;
00547 
00548   if (path_env != 0)
00549     {
00550       path_list = path_env;
00551     }
00552 
00553   return (find_file_from_list (logical_file_name, path_list, search_type));
00554 }

std::string PathResolver::find_file_from_list ( const std::string logical_file_name,
const std::string search_list,
SearchType  search_type = LocalSearch 
) [static]

Returns:
the physical name of the located file or empty string if not found

Definition at line 556 of file PathResolver.cxx.

References PR_find_from_list(), PR_regular_file, and deljobs::string.

Referenced by find_file(), and PathResolverFindFileFromList().

00559 {
00560   std::string result;
00561 
00562   if (!PR_find_from_list (logical_file_name, search_list, PR_regular_file, search_type, result))
00563     {
00564       result = "";
00565     }
00566 
00567   return (result);
00568 }


Generated on Tue Nov 29 23:20:39 2016 for BOSS_7.0.2 by  doxygen 1.4.7