#include <PathResolver.h>
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) |
Definition at line 6 of file PathResolver.h.
Definition at line 9 of file PathResolver.h.
00010 { 00011 Ok, 00012 EnvironmentVariableUndefined, 00013 UnknownDirectory 00014 } SearchPathStatus;
Definition at line 16 of file PathResolver.h.
00017 { 00018 LocalSearch, 00019 RecursiveSearch 00020 } SearchType;
PathResolver::SearchPathStatus PathResolver::check_search_path | ( | const std::string & | search_path | ) | [static] |
search_path
the name of a path-like environment variableOk
, 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] |
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 RecursiveSearchDefinition 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] |
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 RecursiveSearchDefinition 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] |
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
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] |
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
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 }