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 )
74 wordexp_t lShellExpansion;
75 wordexp ( aFilenameExpr.c_str() , &lShellExpansion , 0 );
77 for ( std::size_t i = 0 ; i != lShellExpansion.we_wordc ; i++ )
79 boost::filesystem::path lPath ( lShellExpansion.we_wordv[i] );
81 log (
Debug() ,
"aParentPath is " ,
Quote ( aParentPath.c_str() ) );
82 lPath = boost::filesystem::absolute ( lPath , aParentPath );
85 if ( boost::filesystem::exists ( lPath ) )
87 if ( boost::filesystem::is_regular_file ( lPath ) )
89 aFiles.push_back ( lPath );
94 wordfree ( &lShellExpansion );
96 catch (
const std::exception& aExc )
98 uhal::exception::ExpandingShellExpressionFailed lExc;
99 log ( lExc ,
"Caught exception during shell expansion: " ,
Quote ( aExc.what() ) );
103 if ( ! aFiles.size() )
105 uhal::exception::FileNotFound lExc;
106 log ( lExc ,
"No matching files for expression " ,
Quote ( aFilenameExpr ) ,
" with parent path " ,
Quote ( aParentPath.c_str() ) );
111 log (
Debug() ,
"Shell expansion of " ,
Quote ( aFilenameExpr.c_str() ) ,
" returned:" );
113 for ( std::vector< boost::filesystem::path >::iterator lIt = aFiles.begin() ; lIt != aFiles.end() ; ++lIt )
115 log (
Debug() ,
" > [file] " , lIt->c_str() );