<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>FIFE: engine/core/vfs/vfs.cpp Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="search/search.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="search/search.js"></script> <link href="navtree.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="navtree.js"></script> <script type="text/javascript" src="resize.js"></script> <script type="text/javascript"> $(document).ready(initResizable); </script> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body onload='searchBox.OnSelectItem(0);'> <!-- Generated by Doxygen 1.7.4 --> <script type="text/javascript"><!-- var searchBox = new SearchBox("searchBox", "search",false,'Search'); --></script> <div id="top"> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">FIFE <span id="projectnumber">2008.0</span></div> </td> </tr> </tbody> </table> </div> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li><a href="dirs.html"><span>Directories</span></a></li> <li><a href="examples.html"><span>Examples</span></a></li> <li id="searchli"> <div id="MSearchBox" class="MSearchBoxInactive"> <span class="left"> <img id="MSearchSelect" src="search/mag_sel.png" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" alt=""/> <input type="text" id="MSearchField" value="Search" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" onblur="searchBox.OnSearchFieldFocus(false)" onkeyup="searchBox.OnSearchFieldChange(event)"/> </span><span class="right"> <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> </span> </div> </li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> </ul> </div> </div> <div id="side-nav" class="ui-resizable side-nav-resizable"> <div id="nav-tree"> <div id="nav-tree-contents"> </div> </div> <div id="splitbar" style="-moz-user-select:none;" class="ui-resizable-handle"> </div> </div> <script type="text/javascript"> initNavTree('vfs_8cpp.html',''); </script> <div id="doc-content"> <div class="header"> <div class="headertitle"> <div class="title">vfs.cpp</div> </div> </div> <div class="contents"> <div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/***************************************************************************</span> <a name="l00002"></a>00002 <span class="comment"> * Copyright (C) 2005-2008 by the FIFE team *</span> <a name="l00003"></a>00003 <span class="comment"> * http://www.fifengine.de *</span> <a name="l00004"></a>00004 <span class="comment"> * This file is part of FIFE. *</span> <a name="l00005"></a>00005 <span class="comment"> * *</span> <a name="l00006"></a>00006 <span class="comment"> * FIFE is free software; you can redistribute it and/or *</span> <a name="l00007"></a>00007 <span class="comment"> * modify it under the terms of the GNU Lesser General Public *</span> <a name="l00008"></a>00008 <span class="comment"> * License as published by the Free Software Foundation; either *</span> <a name="l00009"></a>00009 <span class="comment"> * version 2.1 of the License, or (at your option) any later version. *</span> <a name="l00010"></a>00010 <span class="comment"> * *</span> <a name="l00011"></a>00011 <span class="comment"> * This library is distributed in the hope that it will be useful, *</span> <a name="l00012"></a>00012 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of *</span> <a name="l00013"></a>00013 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *</span> <a name="l00014"></a>00014 <span class="comment"> * Lesser General Public License for more details. *</span> <a name="l00015"></a>00015 <span class="comment"> * *</span> <a name="l00016"></a>00016 <span class="comment"> * You should have received a copy of the GNU Lesser General Public *</span> <a name="l00017"></a>00017 <span class="comment"> * License along with this library; if not, write to the *</span> <a name="l00018"></a>00018 <span class="comment"> * Free Software Foundation, Inc., *</span> <a name="l00019"></a>00019 <span class="comment"> * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *</span> <a name="l00020"></a>00020 <span class="comment"> ***************************************************************************/</span> <a name="l00021"></a>00021 <a name="l00022"></a>00022 <span class="comment">// Standard C++ library includes</span> <a name="l00023"></a>00023 <span class="preprocessor">#include <algorithm></span> <a name="l00024"></a>00024 <a name="l00025"></a>00025 <span class="comment">// 3rd party library includes</span> <a name="l00026"></a>00026 <span class="preprocessor">#include <boost/functional.hpp></span> <a name="l00027"></a>00027 <span class="preprocessor">#include <boost/regex.hpp></span> <a name="l00028"></a>00028 <span class="preprocessor">#include <boost/algorithm/string.hpp></span> <a name="l00029"></a>00029 <a name="l00030"></a>00030 <span class="comment">// FIFE includes</span> <a name="l00031"></a>00031 <span class="comment">// These includes are split up in two parts, separated by one empty line</span> <a name="l00032"></a>00032 <span class="comment">// First block: files included from the FIFE root src directory</span> <a name="l00033"></a>00033 <span class="comment">// Second block: files included from the same folder</span> <a name="l00034"></a>00034 <span class="preprocessor">#include "vfs/raw/rawdata.h"</span> <a name="l00035"></a>00035 <span class="preprocessor">#include "util/base/exception.h"</span> <a name="l00036"></a>00036 <span class="preprocessor">#include "util/log/logger.h"</span> <a name="l00037"></a>00037 <a name="l00038"></a>00038 <span class="preprocessor">#include "vfs.h"</span> <a name="l00039"></a>00039 <span class="preprocessor">#include "vfssource.h"</span> <a name="l00040"></a>00040 <span class="preprocessor">#include "vfssourceprovider.h"</span> <a name="l00041"></a>00041 <a name="l00042"></a>00042 <span class="keyword">namespace </span>FIFE { <a name="l00043"></a>00043 <span class="keyword">static</span> Logger _log(LM_VFS); <a name="l00044"></a>00044 <a name="l00045"></a>00045 <a name="l00046"></a><a class="code" href="class_f_i_f_e_1_1_v_f_s.html#a1e259d36e73f4eee60468ab2de4edca9">00046</a> <a class="code" href="class_f_i_f_e_1_1_v_f_s.html#a1e259d36e73f4eee60468ab2de4edca9">VFS::VFS</a>() : m_sources() {} <a name="l00047"></a>00047 <a name="l00048"></a><a class="code" href="class_f_i_f_e_1_1_v_f_s.html#a5bf6cf8a060617dc36732eba05500152">00048</a> <a class="code" href="class_f_i_f_e_1_1_v_f_s.html#a5bf6cf8a060617dc36732eba05500152">VFS::~VFS</a>() { <a name="l00049"></a>00049 cleanup(); <a name="l00050"></a>00050 } <a name="l00051"></a>00051 <a name="l00052"></a>00052 <span class="keywordtype">void</span> VFS::cleanup() { <a name="l00053"></a>00053 type_sources sources = m_sources; <a name="l00054"></a>00054 type_sources::const_iterator end = sources.end(); <a name="l00055"></a>00055 <span class="keywordflow">for</span> (type_sources::iterator i = sources.begin(); i != end; ++i) <a name="l00056"></a>00056 <span class="keyword">delete</span> *i; <a name="l00057"></a>00057 <a name="l00058"></a>00058 type_providers::const_iterator end2 = m_providers.end(); <a name="l00059"></a>00059 <span class="keywordflow">for</span> (type_providers::iterator j = m_providers.begin(); j != end2; ++j) <a name="l00060"></a>00060 <span class="keyword">delete</span> *j; <a name="l00061"></a>00061 <a name="l00062"></a>00062 m_providers.clear(); <a name="l00063"></a>00063 } <a name="l00064"></a>00064 <a name="l00065"></a><a class="code" href="class_f_i_f_e_1_1_v_f_s.html#a4b7c9796c865c8da6ad8027aa19a148a">00065</a> <span class="keywordtype">void</span> <a class="code" href="class_f_i_f_e_1_1_v_f_s.html#a4b7c9796c865c8da6ad8027aa19a148a">VFS::addProvider</a>(<a class="code" href="class_f_i_f_e_1_1_v_f_s_source_provider.html">VFSSourceProvider</a>* provider) { <a name="l00066"></a>00066 provider-><a class="code" href="class_f_i_f_e_1_1_v_f_s_source_provider.html#aa181f5e08ede4c0058ff53b6c2eb8dba">setVFS</a>(<span class="keyword">this</span>); <a name="l00067"></a>00067 m_providers.push_back(provider); <a name="l00068"></a>00068 FL_LOG(_log, <a class="code" href="class_f_i_f_e_1_1_l_msg.html">LMsg</a>(<span class="stringliteral">"new provider: "</span>) << provider-><a class="code" href="class_f_i_f_e_1_1_v_f_s_source_provider.html#ad226418bb85fef560b4f639dc513368a">getName</a>()); <a name="l00069"></a>00069 } <a name="l00070"></a>00070 <a name="l00071"></a><a class="code" href="class_f_i_f_e_1_1_v_f_s.html#af8f37971e4d6663ae658a3604360663b">00071</a> <a class="code" href="class_f_i_f_e_1_1_v_f_s_source.html">VFSSource</a>* <a class="code" href="class_f_i_f_e_1_1_v_f_s.html#af8f37971e4d6663ae658a3604360663b">VFS::createSource</a>(<span class="keyword">const</span> std::string& path)<span class="keyword"> const </span>{ <a name="l00072"></a>00072 <span class="keywordflow">if</span> ( m_usedfiles.count(path) ) { <a name="l00073"></a>00073 FL_WARN(_log, <a class="code" href="class_f_i_f_e_1_1_l_msg.html">LMsg</a>(path) << <span class="stringliteral">" is already used as VFS source"</span>); <a name="l00074"></a>00074 <span class="keywordflow">return</span> 0; <a name="l00075"></a>00075 } <a name="l00076"></a>00076 <a name="l00077"></a>00077 type_providers::const_iterator end = m_providers.end(); <a name="l00078"></a>00078 <span class="keywordflow">for</span> (type_providers::const_iterator i = m_providers.begin(); i != end; ++i) { <a name="l00079"></a>00079 <span class="keyword">const</span> <a class="code" href="class_f_i_f_e_1_1_v_f_s_source_provider.html">VFSSourceProvider</a>* provider = *i; <a name="l00080"></a>00080 <span class="keywordflow">if</span> (!provider-><a class="code" href="class_f_i_f_e_1_1_v_f_s_source_provider.html#a5b74e4ac6d6cfdfc7b137735ad4b0eb5">isReadable</a>(path)) <a name="l00081"></a>00081 <span class="keywordflow">continue</span>; <a name="l00082"></a>00082 <a name="l00083"></a>00083 <span class="keywordflow">try</span> { <a name="l00084"></a>00084 <a class="code" href="class_f_i_f_e_1_1_v_f_s_source.html">VFSSource</a>* source = provider-><a class="code" href="class_f_i_f_e_1_1_v_f_s_source_provider.html#a4c1fce8557da05d17d600d521c3ba7ae">createSource</a>(path); <a name="l00085"></a>00085 m_usedfiles.insert(path); <a name="l00086"></a>00086 <span class="keywordflow">return</span> source; <a name="l00087"></a>00087 } <span class="keywordflow">catch</span> (<span class="keyword">const</span> <a class="code" href="class_f_i_f_e_1_1_exception.html">Exception</a>& ex) { <a name="l00088"></a>00088 FL_WARN(_log, <a class="code" href="class_f_i_f_e_1_1_l_msg.html">LMsg</a>(provider-><a class="code" href="class_f_i_f_e_1_1_v_f_s_source_provider.html#ad226418bb85fef560b4f639dc513368a">getName</a>()) << <span class="stringliteral">" thought it could load "</span> << path << <span class="stringliteral">" but didn't succeed ("</span> << ex.<a class="code" href="class_f_i_f_e_1_1_exception.html#a0872a41cac203dd2d8541d17089ee6f4">what</a>() << <span class="stringliteral">")"</span>); <a name="l00089"></a>00089 <span class="keywordflow">continue</span>; <a name="l00090"></a>00090 } <span class="keywordflow">catch</span> (...) { <a name="l00091"></a>00091 FL_WARN(_log, <a class="code" href="class_f_i_f_e_1_1_l_msg.html">LMsg</a>(provider-><a class="code" href="class_f_i_f_e_1_1_v_f_s_source_provider.html#ad226418bb85fef560b4f639dc513368a">getName</a>()) << <span class="stringliteral">" thought it could load "</span> << path << <span class="stringliteral">" but didn't succeed (unkown exception)"</span>); <a name="l00092"></a>00092 <span class="keywordflow">continue</span>; <a name="l00093"></a>00093 } <a name="l00094"></a>00094 } <a name="l00095"></a>00095 <a name="l00096"></a>00096 FL_WARN(_log, <a class="code" href="class_f_i_f_e_1_1_l_msg.html">LMsg</a>(<span class="stringliteral">"no provider for "</span>) << path << <span class="stringliteral">" found"</span>); <a name="l00097"></a>00097 <span class="keywordflow">return</span> 0; <a name="l00098"></a>00098 } <a name="l00099"></a>00099 <a name="l00100"></a><a class="code" href="class_f_i_f_e_1_1_v_f_s.html#a08bb8b750490d6eea8ff0175e08f0b45">00100</a> <span class="keywordtype">void</span> <a class="code" href="class_f_i_f_e_1_1_v_f_s.html#a08bb8b750490d6eea8ff0175e08f0b45">VFS::addNewSource</a>(<span class="keyword">const</span> std::string& path) { <a name="l00101"></a>00101 <a class="code" href="class_f_i_f_e_1_1_v_f_s_source.html">VFSSource</a>* source = <a class="code" href="class_f_i_f_e_1_1_v_f_s.html#af8f37971e4d6663ae658a3604360663b">createSource</a>(path); <a name="l00102"></a>00102 <span class="keywordflow">if</span> (source) { <a name="l00103"></a>00103 <a class="code" href="class_f_i_f_e_1_1_v_f_s.html#a354ffe8e0a373a0560f718be6a2b02a3">addSource</a>(source); <a name="l00104"></a>00104 } <span class="keywordflow">else</span> { <a name="l00105"></a>00105 FL_WARN(_log, <a class="code" href="class_f_i_f_e_1_1_l_msg.html">LMsg</a>(<span class="stringliteral">"Failed to add new VFS source: "</span>) << path); <a name="l00106"></a>00106 } <a name="l00107"></a>00107 } <a name="l00108"></a>00108 <a name="l00109"></a><a class="code" href="class_f_i_f_e_1_1_v_f_s.html#a354ffe8e0a373a0560f718be6a2b02a3">00109</a> <span class="keywordtype">void</span> <a class="code" href="class_f_i_f_e_1_1_v_f_s.html#a354ffe8e0a373a0560f718be6a2b02a3">VFS::addSource</a>(<a class="code" href="class_f_i_f_e_1_1_v_f_s_source.html">VFSSource</a>* source) { <a name="l00110"></a>00110 m_sources.push_back(source); <a name="l00111"></a>00111 } <a name="l00112"></a>00112 <a name="l00113"></a><a class="code" href="class_f_i_f_e_1_1_v_f_s.html#a89162cabc1c1ed06573989ac11bb5a39">00113</a> <span class="keywordtype">void</span> <a class="code" href="class_f_i_f_e_1_1_v_f_s.html#a89162cabc1c1ed06573989ac11bb5a39">VFS::removeSource</a>(<a class="code" href="class_f_i_f_e_1_1_v_f_s_source.html">VFSSource</a>* source) { <a name="l00114"></a>00114 type_sources::iterator i = std::find(m_sources.begin(), m_sources.end(), source); <a name="l00115"></a>00115 <span class="keywordflow">if</span> (i != m_sources.end()) <a name="l00116"></a>00116 m_sources.erase(i); <a name="l00117"></a>00117 } <a name="l00118"></a>00118 <a name="l00119"></a>00119 <a class="code" href="class_f_i_f_e_1_1_v_f_s_source.html">VFSSource</a>* VFS::getSourceForFile(<span class="keyword">const</span> std::string& file)<span class="keyword"> const </span>{ <a name="l00120"></a>00120 type_sources::const_iterator i = std::find_if(m_sources.begin(), m_sources.end(), <a name="l00121"></a>00121 boost::bind2nd(boost::mem_fun(&<a class="code" href="class_f_i_f_e_1_1_v_f_s_source.html#a39d81b4693a50b38209521bdd571ee64">VFSSource::fileExists</a>), file)); <a name="l00122"></a>00122 <span class="keywordflow">if</span> (i == m_sources.end()) { <a name="l00123"></a>00123 FL_WARN(_log, <a class="code" href="class_f_i_f_e_1_1_l_msg.html">LMsg</a>(<span class="stringliteral">"no source for "</span>) << file << <span class="stringliteral">" found"</span>); <a name="l00124"></a>00124 <span class="keywordflow">return</span> 0; <a name="l00125"></a>00125 } <a name="l00126"></a>00126 <a name="l00127"></a>00127 <span class="keywordflow">return</span> *i; <a name="l00128"></a>00128 } <a name="l00129"></a>00129 <a name="l00130"></a><a class="code" href="class_f_i_f_e_1_1_v_f_s.html#aafe2819855c9d419799587a3c6b23b13">00130</a> <span class="keywordtype">bool</span> <a class="code" href="class_f_i_f_e_1_1_v_f_s.html#aafe2819855c9d419799587a3c6b23b13">VFS::exists</a>(<span class="keyword">const</span> std::string& file)<span class="keyword"> const </span>{ <a name="l00131"></a>00131 <span class="keywordflow">return</span> getSourceForFile(file); <a name="l00132"></a>00132 } <a name="l00133"></a>00133 <a name="l00134"></a><a class="code" href="class_f_i_f_e_1_1_v_f_s.html#a9bb374029f75d6d77c9c4a1c656e2a2c">00134</a> <span class="keywordtype">bool</span> <a class="code" href="class_f_i_f_e_1_1_v_f_s.html#a9bb374029f75d6d77c9c4a1c656e2a2c">VFS::isDirectory</a>(<span class="keyword">const</span> std::string& path)<span class="keyword"> const </span>{ <a name="l00135"></a>00135 std::vector<std::string> tokens; <a name="l00136"></a>00136 <span class="comment">// Add a slash in case there isn't one in the string</span> <a name="l00137"></a>00137 <span class="keyword">const</span> std::string newpath = path + <span class="stringliteral">"/"</span>; <a name="l00138"></a>00138 boost::algorithm::split(tokens, newpath, boost::algorithm::is_any_of(<span class="stringliteral">"/"</span>)); <a name="l00139"></a>00139 <a name="l00140"></a>00140 std::string currentpath = <span class="stringliteral">"/"</span>; <a name="l00141"></a>00141 std::vector<std::string>::const_iterator token=tokens.begin(); <a name="l00142"></a>00142 <span class="keywordflow">while</span> (token != tokens.end()) { <a name="l00143"></a>00143 <span class="keywordflow">if</span> (*token != <span class="stringliteral">""</span>) { <a name="l00144"></a>00144 <span class="keywordflow">if</span> (*token != <span class="stringliteral">"."</span> && *token != <span class="stringliteral">".."</span> && <a class="code" href="class_f_i_f_e_1_1_v_f_s.html#a54297de30eccd4fa077fa442671d4364">listDirectories</a>(currentpath, *token).size() == 0) { <a name="l00145"></a>00145 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00146"></a>00146 } <span class="keywordflow">else</span> { <a name="l00147"></a>00147 currentpath += *token + <span class="stringliteral">"/"</span>; <a name="l00148"></a>00148 } <a name="l00149"></a>00149 } <a name="l00150"></a>00150 token++; <a name="l00151"></a>00151 } <a name="l00152"></a>00152 <a name="l00153"></a>00153 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00154"></a>00154 } <a name="l00155"></a>00155 <a name="l00156"></a><a class="code" href="class_f_i_f_e_1_1_v_f_s.html#ac467a514cc9f2b7099ab942c66260114">00156</a> <a class="code" href="class_f_i_f_e_1_1_raw_data.html">RawData</a>* <a class="code" href="class_f_i_f_e_1_1_v_f_s.html#ac467a514cc9f2b7099ab942c66260114">VFS::open</a>(<span class="keyword">const</span> std::string& path) { <a name="l00157"></a>00157 FL_DBG(_log, <a class="code" href="class_f_i_f_e_1_1_l_msg.html">LMsg</a>(<span class="stringliteral">"Opening: "</span>) << path); <a name="l00158"></a>00158 <a name="l00159"></a>00159 <a class="code" href="class_f_i_f_e_1_1_v_f_s_source.html">VFSSource</a>* source = getSourceForFile(path); <a name="l00160"></a>00160 <span class="keywordflow">if</span> (!source) <a name="l00161"></a>00161 <span class="keywordflow">throw</span> NotFound(path); <a name="l00162"></a>00162 <a name="l00163"></a>00163 <span class="keywordflow">return</span> source-><a class="code" href="class_f_i_f_e_1_1_v_f_s_source.html#a21d8e42605bfe2bff89f5b553f915bf1">open</a>(path); <a name="l00164"></a>00164 } <a name="l00165"></a>00165 <a name="l00166"></a><a class="code" href="class_f_i_f_e_1_1_v_f_s.html#a4935fcc3d6c7317aeb11363272ab2407">00166</a> std::set<std::string> <a class="code" href="class_f_i_f_e_1_1_v_f_s.html#a4935fcc3d6c7317aeb11363272ab2407">VFS::listFiles</a>(<span class="keyword">const</span> std::string& pathstr)<span class="keyword"> const </span>{ <a name="l00167"></a>00167 std::set<std::string> list; <a name="l00168"></a>00168 type_sources::const_iterator end = m_sources.end(); <a name="l00169"></a>00169 <span class="keywordflow">for</span> (type_sources::const_iterator i = m_sources.begin(); i != end; ++i) { <a name="l00170"></a>00170 std::set<std::string> sourcelist = (*i)->listFiles(pathstr); <a name="l00171"></a>00171 list.insert(sourcelist.begin(), sourcelist.end()); <a name="l00172"></a>00172 } <a name="l00173"></a>00173 <a name="l00174"></a>00174 <span class="keywordflow">return</span> list; <a name="l00175"></a>00175 } <a name="l00176"></a>00176 <a name="l00177"></a><a class="code" href="class_f_i_f_e_1_1_v_f_s.html#aa023d6e7e0ece356c08a46a72e2852a7">00177</a> std::set<std::string> <a class="code" href="class_f_i_f_e_1_1_v_f_s.html#a4935fcc3d6c7317aeb11363272ab2407">VFS::listFiles</a>(<span class="keyword">const</span> std::string& path, <span class="keyword">const</span> std::string& filterregex)<span class="keyword"> const </span>{ <a name="l00178"></a>00178 std::set<std::string> list = <a class="code" href="class_f_i_f_e_1_1_v_f_s.html#a4935fcc3d6c7317aeb11363272ab2407">listFiles</a>(path); <a name="l00179"></a>00179 <span class="keywordflow">return</span> filterList(list, filterregex); <a name="l00180"></a>00180 } <a name="l00181"></a>00181 <a name="l00182"></a><a class="code" href="class_f_i_f_e_1_1_v_f_s.html#a54297de30eccd4fa077fa442671d4364">00182</a> std::set<std::string> <a class="code" href="class_f_i_f_e_1_1_v_f_s.html#a54297de30eccd4fa077fa442671d4364">VFS::listDirectories</a>(<span class="keyword">const</span> std::string& pathstr)<span class="keyword"> const </span>{ <a name="l00183"></a>00183 std::set<std::string> list; <a name="l00184"></a>00184 type_sources::const_iterator end = m_sources.end(); <a name="l00185"></a>00185 <span class="keywordflow">for</span> (type_sources::const_iterator i = m_sources.begin(); i != end; ++i) { <a name="l00186"></a>00186 std::set<std::string> sourcelist = (*i)->listDirectories(pathstr); <a name="l00187"></a>00187 list.insert(sourcelist.begin(), sourcelist.end()); <a name="l00188"></a>00188 } <a name="l00189"></a>00189 <a name="l00190"></a>00190 <span class="keywordflow">return</span> list; <a name="l00191"></a>00191 } <a name="l00192"></a>00192 <a name="l00193"></a><a class="code" href="class_f_i_f_e_1_1_v_f_s.html#adac6613b0502d0212a6d83fa0dfd35f1">00193</a> std::set<std::string> <a class="code" href="class_f_i_f_e_1_1_v_f_s.html#a54297de30eccd4fa077fa442671d4364">VFS::listDirectories</a>(<span class="keyword">const</span> std::string& path, <span class="keyword">const</span> std::string& filterregex)<span class="keyword"> const </span>{ <a name="l00194"></a>00194 std::set<std::string> list = <a class="code" href="class_f_i_f_e_1_1_v_f_s.html#a54297de30eccd4fa077fa442671d4364">listDirectories</a>(path); <a name="l00195"></a>00195 <span class="keywordflow">return</span> filterList(list, filterregex); <a name="l00196"></a>00196 } <a name="l00197"></a>00197 <a name="l00198"></a>00198 std::set<std::string> VFS::filterList(<span class="keyword">const</span> std::set<std::string>& list, <span class="keyword">const</span> std::string& fregex)<span class="keyword"> const </span>{ <a name="l00199"></a>00199 std::set<std::string> results; <a name="l00200"></a>00200 boost::regex regex(fregex); <a name="l00201"></a>00201 std::set<std::string>::const_iterator end = list.end(); <a name="l00202"></a>00202 <span class="keywordflow">for</span> (std::set<std::string>::const_iterator i = list.begin(); i != end;) { <a name="l00203"></a>00203 boost::cmatch match; <a name="l00204"></a>00204 <span class="keywordflow">if</span> (boost::regex_match((*i).c_str(), match, regex)) { <a name="l00205"></a>00205 results.insert(*i); <a name="l00206"></a>00206 } <a name="l00207"></a>00207 ++i; <a name="l00208"></a>00208 } <a name="l00209"></a>00209 <span class="keywordflow">return</span> results; <a name="l00210"></a>00210 } <a name="l00211"></a>00211 } </pre></div></div> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><b>vfs.cpp</b> </li> <li class="footer">Generated on Sun Jul 10 2011 for FIFE by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </li> </ul> </div> <!-- window showing the filter options --> <div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Enumerator</a></div> <!-- iframe showing the search results (closed by default) --> <div id="MSearchResultsWindow"> <iframe src="javascript:void(0)" frameborder="0" name="MSearchResults" id="MSearchResults"> </iframe> </div> </body> </html>