38 #include "uhal/log/log.hpp" 51 boost::spirit::qi::phrase_parse ( aSemicolonDelimitedUriList.begin() , aSemicolonDelimitedUriList.end() , lGrammar , boost::spirit::ascii::space , aUriList );
53 catch (
const std::exception& aExc )
55 exception::UriListParsingError lExc;
56 log ( lExc ,
"Expression " ,
Quote ( aSemicolonDelimitedUriList ) ,
" must be a semicolon delimeted list and all files must be in the form " ,
Quote (
"protocol://address" ) );
60 log (
Debug() ,
"Parsed " ,
Quote ( aSemicolonDelimitedUriList ) ,
" to:" );
62 for ( std::vector< std::pair<std::string, std::string> >::iterator lIt = aUriList.begin() ; lIt != aUriList.end() ; ++lIt )
64 log (
Debug() ,
" > [" , lIt->first ,
"] " ,
Quote ( lIt->second ) );
69 void ShellExpandFilenameExpr (
const std::string& aFilenameExpr ,
const boost::filesystem::path& aParentPath , std::vector< boost::filesystem::path >& aFiles )
75 wordexp_t lShellExpansion;
76 wordexp ( aFilenameExpr.c_str() , &lShellExpansion , 0 );
78 for ( std::size_t i = 0 ; i != lShellExpansion.we_wordc ; i++ )
80 boost::filesystem::path lPath ( lShellExpansion.we_wordv[i] );
81 log (
Debug() ,
"lPath was " ,
Quote ( lPath.c_str() ) );
82 log (
Debug() ,
"aParentPath is " ,
Quote ( aParentPath.c_str() ) );
83 lPath = boost::filesystem::absolute ( lPath , aParentPath );
84 log (
Debug() ,
"lPath now " ,
Quote ( lPath.c_str() ) );
86 if ( boost::filesystem::exists ( lPath ) )
88 if ( boost::filesystem::is_regular_file ( lPath ) )
90 aFiles.push_back ( lPath );
95 wordfree ( &lShellExpansion );
97 catch (
const std::exception& aExc )
99 uhal::exception::ExpandingShellExpressionFailed lExc;
100 log ( lExc ,
"Caught exception: " ,
Quote ( aExc.what() ) );
104 if ( ! aFiles.size() )
106 uhal::exception::FileNotFound lExc;
107 log ( lExc ,
"No matching files for expression " ,
Quote ( aFilenameExpr ) ,
" with parent path " ,
Quote ( aParentPath.c_str() ) );
112 log (
Debug() ,
"Shell expansion of " ,
Quote ( aFilenameExpr.c_str() ) ,
" returned:" );
114 for ( std::vector< boost::filesystem::path >::iterator lIt = aFiles.begin() ; lIt != aFiles.end() ; ++lIt )
116 log (
Debug() ,
" > [file] " , lIt->c_str() );
void ParseSemicolonDelimitedUriList(const std::string &aSemicolonDelimitedUriList, std::vector< std::pair< std::string, std::string > > &aUriList)
Parse a semicolon delimited list of URIs into a vector of protocol/address pairs. ...
void ShellExpandFilenameExpr(const std::string &aFilenameExpr, const boost::filesystem::path &aParentPath, std::vector< boost::filesystem::path > &aFiles)
Perform shell expansion of a linux shell expression ( e.g.
_Quote< T > Quote(const T &aT)
The BOOST::SPIRIT grammar for parsing the Semicolon delimited URI list into a vector of protocol-URI ...