13#include <boost/algorithm/string/classification.hpp>
14#include <boost/algorithm/string/split.hpp>
15#include <boost/filesystem.hpp>
20namespace bf = boost::filesystem;
23static const char* path_separator =
",:";
31 static bool PR_find(
const bf::path& file,
const string& search_list,
PR_file_type file_type,
40 ( file_type ==
PR_directory && is_directory( file ) ) ) {
41 result = bf::system_complete( file ).string();
44 }
catch (
const bf::filesystem_error& ) {}
49 bf::path local = bf::initial_path() / file;
51 ( file_type ==
PR_directory && is_directory( local ) ) ) {
52 result = bf::system_complete( file ).string();
55 }
catch (
const bf::filesystem_error& ) {}
59 split( spv, search_list, boost::is_any_of( path_separator ), boost::token_compress_on );
60 for (
const auto& itr : spv ) {
62 bf::path fp = itr / file;
67 result = bf::system_complete( fp ).string();
70 }
catch (
const bf::filesystem_error& ) {}
75 bf::recursive_directory_iterator end_itr;
77 for ( bf::recursive_directory_iterator ritr( itr ); ritr != end_itr; ++ritr ) {
80 if ( !is_directory( bf::path( *ritr ) ) ) {
continue; }
82 bf::path fp2 = bf::path( *ritr ) / file;
85 result = bf::system_complete( fp2 ).string();
89 }
catch (
const bf::filesystem_error& ) {}
99 std::string path_list;
107 std::string result(
"" );
109 bf::path lfn( logical_file_name );
129 std::string path_list;
139 if ( !PR_find( logical_file_name, search_list,
PR_directory, search_type, result ) ) { result =
""; }
145 std::string path_list;
149 boost::split( spv, path_list, boost::is_any_of( path_separator ), boost::token_compress_on );
152 for (
const auto& itr : spv ) {
static std::string find_directory_from_list(const std::string &logical_file_name, const std::string &search_list, SearchType search_type=LocalSearch)
static std::string find_file(const std::string &logical_file_name, const std::string &search_path, SearchType search_type=LocalSearch)
static SearchPathStatus check_search_path(const std::string &search_path)
@ EnvironmentVariableUndefined
static std::string find_directory(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)
Note: OS specific details for environment resolution.
GAUDI_API std::string PathResolverFindXMLFile(const std::string &logical_file_name)
GAUDI_API std::vector< std::string > getEnv()
get all environment variables
GAUDI_API std::string PathResolverFindDataFile(const std::string &logical_file_name)
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)