BOSS 7.0.2
BESIII Offline Software System
Loading...
Searching...
No Matches
PathResolver Class Reference

#include <PathResolver.h>

Public Types

enum  SearchPathStatus {
  Ok , EnvironmentVariableUndefined , UnknownDirectory , Ok ,
  EnvironmentVariableUndefined , UnknownDirectory
}
 
enum  SearchType { LocalSearch , RecursiveSearch , LocalSearch , RecursiveSearch }
 
enum  SearchPathStatus {
  Ok , EnvironmentVariableUndefined , UnknownDirectory , Ok ,
  EnvironmentVariableUndefined , UnknownDirectory
}
 
enum  SearchType { LocalSearch , RecursiveSearch , 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)
 
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

Member Enumeration Documentation

◆ SearchPathStatus [1/2]

◆ SearchPathStatus [2/2]

Enumerator
Ok 
EnvironmentVariableUndefined 
UnknownDirectory 
Ok 
EnvironmentVariableUndefined 
UnknownDirectory 

Definition at line 9 of file InstallArea/include/HltTools/HltTools/PathResolver.h.

◆ SearchType [1/2]

◆ SearchType [2/2]

Enumerator
LocalSearch 
RecursiveSearch 
LocalSearch 
RecursiveSearch 

Definition at line 16 of file InstallArea/include/HltTools/HltTools/PathResolver.h.

Member Function Documentation

◆ check_search_path() [1/2]

PathResolver::SearchPathStatus 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 600 of file PathResolver.cxx.

601{
602 const char* path_env = ::getenv (search_path.c_str ());
603
604 if (path_env == 0) return (EnvironmentVariableUndefined);
605
606#ifdef WIN32
607 static const char path_separator = ';';
608#else
609 static const char path_separator = ':';
610#endif
611
612 std::string path_list (path_env);
613
614 std::string::size_type pos = 0;
615
616 for (int i = 0;;i++)
617 {
618 bool ending = false;
619
620 std::string::size_type next = path_list.find (path_separator, pos);
621
622 std::string path = path_list.substr (pos, next - pos);
623
624 if (next == std::string::npos)
625 {
626 path = path_list.substr (pos);
627 ending = true;
628 }
629 else
630 {
631 path = path_list.substr (pos, next - pos);
632 pos = next + 1;
633 }
634
635 std::string real_name = "";
636
637 if (!PR_test_exist (path, real_name, PR_directory))
638 {
639 return (UnknownDirectory);
640 }
641
642 if (ending) break;
643 }
644
645 return (Ok);
646}
@ PR_directory
Index next(Index i)
Definition: EvtCyclic3.cc:107

Referenced by PathResolverCheckSearchPath().

◆ check_search_path() [2/2]

static SearchPathStatus 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

◆ find_directory() [1/2]

std::string 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 570 of file PathResolver.cxx.

573{
574 const char* path_env = ::getenv (search_path.c_str ());
575
576 std::string path_list;
577
578 if (path_env != 0)
579 {
580 path_list = path_env;
581 }
582
583 return (find_directory_from_list (logical_file_name, path_list, search_type));
584}
static std::string find_directory_from_list(const std::string &logical_file_name, const std::string &search_list, SearchType search_type=LocalSearch)

Referenced by PathResolverFindDirectory().

◆ find_directory() [2/2]

static std::string 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

◆ find_directory_from_list() [1/2]

std::string 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 586 of file PathResolver.cxx.

589{
590 std::string result;
591
592 if (!PR_find_from_list (logical_file_name, search_list, PR_directory, search_type, result))
593 {
594 result = "";
595 }
596
597 return (result);
598}

Referenced by find_directory(), and PathResolverFindDirectoryFromList().

◆ find_directory_from_list() [2/2]

static std::string 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

◆ find_file() [1/2]

std::string 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 540 of file PathResolver.cxx.

543{
544 const char* path_env = ::getenv (search_path.c_str ());
545
546 std::string path_list;
547
548 if (path_env != 0)
549 {
550 path_list = path_env;
551 }
552
553 return (find_file_from_list (logical_file_name, path_list, search_type));
554}
static std::string find_file_from_list(const std::string &logical_file_name, const std::string &search_list, SearchType search_type=LocalSearch)

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

◆ find_file() [2/2]

static std::string 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

◆ find_file_from_list() [1/2]

std::string 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 556 of file PathResolver.cxx.

559{
560 std::string result;
561
562 if (!PR_find_from_list (logical_file_name, search_list, PR_regular_file, search_type, result))
563 {
564 result = "";
565 }
566
567 return (result);
568}
@ PR_regular_file

Referenced by find_file(), and PathResolverFindFileFromList().

◆ find_file_from_list() [2/2]

static std::string 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

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