9 #include <boost/regex.hpp> 10 #include <boost/filesystem/operations.hpp> 11 #include <boost/filesystem/exception.hpp> 13 namespace fs =
boost::filesystem;
18 "<\\s*[^>]*\\s+(?:HREF|SRC)" 19 "\\s*=\\s*\"([^\"]*)\"",
40 const string& library_name,
41 const path& full_path )
44 if ( !fs::is_directory ( full_path ) )
46 m_paths[ relative_to ( full_path, fs::initial_path() ) ] |= m_present;
53 const string& library_name,
54 const path& full_path,
55 const string& contents )
57 string::const_iterator start ( contents.begin() );
58 string::const_iterator end ( contents.end() );
59 boost::match_results< string::const_iterator > what;
60 boost::match_flag_type flags =
boost::match_default;
62 while ( boost::regex_search ( start, end, what, url_regex, flags) )
66 do_url ( string ( what[1].first, what[1].second ),
67 library_name, full_path );
69 start = what[0].second;
70 flags |= boost::match_prev_avail;
71 flags |= boost::match_not_bob;
78 const path& source_path )
81 || url.find (
"mailto:" ) == 0
82 || url.find (
"http:" ) == 0
83 || url.find (
"https:" ) == 0
84 || url.find (
"ftp:" ) == 0
85 || url.find (
"news:" ) == 0
86 || url.find (
"javascript:" ) == 0
92 if ( url.find (
"file:" ) == 0 )
95 error ( library_name, source_path,
"invalid URL (hardwired file): " + url );
100 if ( url.find_first_of (
" <>\"{}|\\^[]'" ) != string::npos )
103 error ( library_name, source_path,
"invalid character in URL: " + url );
107 string plain_url ( url );
108 string::size_type pos ( plain_url.find (
'#' ) );
109 if ( pos != string::npos )
111 plain_url.erase ( pos );
113 if ( url.find (
'#', pos + 1 ) != string::npos )
116 error ( library_name, source_path,
"invalid bookmark: " + url );
121 if ( plain_url[0] ==
'.' && plain_url[1] ==
'/' )
123 plain_url.erase ( 0, 2 );
131 target_path = source_path.branch_path() /= path ( plain_url, fs::no_check );
133 catch (
const fs::filesystem_error& )
136 error ( library_name, source_path,
"invalid URL: " + url );
141 std::pair<
const string,
int > entry (
142 relative_to ( target_path, fs::initial_path() ), 0 );
143 m_path_map::iterator itr ( m_paths.find ( entry.first ) );
144 if ( itr == m_paths.end() )
146 if ( fs::exists ( target_path ) )
148 entry.second = m_present;
150 itr = m_paths.insert ( entry ).first;
154 itr->second |= m_linked_to;
157 if ( (itr->second & m_present) == 0 )
160 error ( library_name, source_path,
"broken link: " + url );
168 for ( m_path_map::const_iterator itr = m_paths.begin();
169 itr != m_paths.end(); ++itr )
172 if ( (itr->second & m_linked_to) != m_linked_to
173 && (itr->first.rfind (
".html" ) == itr->first.size() - 5
174 || itr->first.rfind (
".htm" ) == itr->first.size() - 4)
176 && itr->first.rfind (
"index.html" ) == string::npos
177 && itr->first.rfind (
"index.htm" ) == string::npos )
180 path full_path ( fs::initial_path() / path (itr->first, fs::no_check) );
181 error ( impute_library ( full_path ), full_path,
"unlinked file" );
boost::regex url_regex("<\*[^>]*\+(?:HREF|SRC)" "\*=\*\[^\*)\, boost::regbase::normal|boost::regbase::icase)
virtual void inspect(const std::string &library_name, const path &full_path)
static const LifeV::UInt elm_nodes_num[]
virtual void inspect(const std::string &library_name, const path &full_path, const std::string &contents)
void do_url(const string &url, const string &library_name, const path &full_source_path)