18 # pragma warning( disable : 4996 )
26 #include <boost/algorithm/string/classification.hpp>
27 #include <boost/algorithm/string/split.hpp>
28 #include <boost/filesystem.hpp>
30 namespace bf = boost::filesystem;
34 static const char* path_separator =
",;";
36 static const char* path_separator =
",:";
52 PathResolver::SearchType search_type,
string& result ) {
60 ( file_type ==
PR_directory && is_directory( file ) ) ) {
61 result = bf::system_complete( file ).
string();
64 }
catch (
const bf::filesystem_error& ) {}
69 bf::path local = bf::initial_path() / file;
71 ( file_type ==
PR_directory && is_directory( local ) ) ) {
72 result = bf::system_complete( file ).
string();
75 }
catch (
const bf::filesystem_error& ) {}
79 split( spv, search_list, boost::is_any_of( path_separator ), boost::token_compress_on );
80 for (
const auto& itr : spv ) {
87 result = bf::system_complete( fp ).
string();
90 }
catch (
const bf::filesystem_error& ) {}
93 if ( search_type == PathResolver::RecursiveSearch && is_directory(
bf::path( itr ) ) ) {
95 bf::recursive_directory_iterator end_itr;
97 for ( bf::recursive_directory_iterator ritr( itr ); ritr != end_itr; ++ritr ) {
100 if ( !is_directory(
bf::path( *ritr ) ) ) {
continue; }
104 ( file_type ==
PR_directory && is_directory( fp2 ) ) ) {
105 result = bf::system_complete( fp2 ).
string();
109 }
catch (
const bf::filesystem_error& ) {}
124 return ( find_file_from_list( logical_file_name, path_list, search_type ) );
158 return ( find_directory_from_list( logical_file_name, path_list, search_type ) );
167 if ( !PR_find( logical_file_name, search_list,
PR_directory, search_type, result ) ) { result =
""; }
176 if ( !
System::getEnv( search_path, path_list ) )
return ( EnvironmentVariableUndefined );
179 boost::split( spv, path_list, boost::is_any_of( path_separator ), boost::token_compress_on );
182 for (
const auto& itr : spv ) {
184 if ( !is_directory(
pp ) ) {
return ( UnknownDirectory ); }
186 }
catch (
const bf::filesystem_error& ) {
return ( UnknownDirectory ); }
194 return PathResolver::find_file( logical_file_name,
"XMLPATH" );
198 return PathResolver::find_file( logical_file_name,
"DATAPATH" );